Iterate over Members instead of Users in discourse integration

This commit is contained in:
Tanner Collin 2022-04-20 02:34:30 +00:00
parent 5079f8985f
commit 98768cb7dd

View File

@ -32,11 +32,11 @@ class Command(BaseCommand):
'protospace_instructors': [], 'protospace_instructors': [],
} }
for user in User.objects.exclude(member__discourse_username__exact=''): for member in models.Member.objects.exclude(discourse_username__exact=''):
username = user.member.discourse_username username = member.discourse_username
# handle non-member vs. member # handle non-member vs. member
if user.member.paused_date: if member.paused_date:
add_to_group['protospace_members_former'].append(username) add_to_group['protospace_members_former'].append(username)
remove_from_group['directors_current'].append(username) remove_from_group['directors_current'].append(username)
remove_from_group['protospace_members'].append(username) remove_from_group['protospace_members'].append(username)
@ -49,13 +49,13 @@ class Command(BaseCommand):
remove_from_group['protospace_members_former'].append(username) remove_from_group['protospace_members_former'].append(username)
# handle directors # handle directors
if user.member.is_director: if member.is_director:
add_to_group['directors_current'].append(username) add_to_group['directors_current'].append(username)
else: else:
remove_from_group['directors_current'].append(username) remove_from_group['directors_current'].append(username)
# handle instructors # handle instructors
if user.member.is_instructor: if member.is_instructor:
add_to_group['protospace_instructors'].append(username) add_to_group['protospace_instructors'].append(username)
else: else:
remove_from_group['protospace_instructors'].append(username) remove_from_group['protospace_instructors'].append(username)