diff --git a/alliance_auth/settings.py b/alliance_auth/settings.py index 211efedc..d689ac98 100644 --- a/alliance_auth/settings.py +++ b/alliance_auth/settings.py @@ -144,7 +144,7 @@ DEFAULT_ALLIANCE_GROUP = 'AllianceMember' # ALLIANCE INFO ALLIANCE_ID = '0' -ALLIANCE_NAME = 'Alliance Name' +ALLIANCE_NAME = 'SomeAllianceName' # Jabber Prosody Info JABBER_URL = "@someaddress.com" diff --git a/celerytask/tasks.py b/celerytask/tasks.py index 26445292..837eebb3 100644 --- a/celerytask/tasks.py +++ b/celerytask/tasks.py @@ -50,47 +50,61 @@ def update_forum_groups(user): def add_to_databases(user, groups, syncgroups): - authserviceinfo = AuthServicesInfo.objects.get(user=user) - update = False - for group in groups: - syncgroup = syncgroups.filter(groupname=group.name) - if not syncgroup: - # gotta create group - # create syncgroup - # create service groups - synccache = SyncGroupCache() - synccache.groupname = group.name - synccache.user = user - synccache.save() - update = True + authserviceinfo = None + try: + authserviceinfo = AuthServicesInfo.objects.get(user=user) + except: + pass - if update: - if authserviceinfo.jabber_username != "": - update_jabber_groups(user) - if authserviceinfo.mumble_username != "": - update_mumble_groups(user) - if authserviceinfo.forum_username != "": - update_forum_groups(user) + if authserviceinfo: + authserviceinfo = AuthServicesInfo.objects.get(user=user) + + update = False + for group in groups: + syncgroup = syncgroups.filter(groupname=group.name) + if not syncgroup: + # gotta create group + # create syncgroup + # create service groups + synccache = SyncGroupCache() + synccache.groupname = group.name + synccache.user = user + synccache.save() + update = True + + if update: + if authserviceinfo.jabber_username != "": + update_jabber_groups(user) + if authserviceinfo.mumble_username != "": + update_mumble_groups(user) + if authserviceinfo.forum_username != "": + update_forum_groups(user) def remove_from_databases(user, groups, syncgroups): - authserviceinfo = AuthServicesInfo.objects.get(user=user) - update = False - for syncgroup in syncgroups: - group = groups.filter(name=syncgroup.groupname) + authserviceinfo = None + try: + authserviceinfo = AuthServicesInfo.objects.get(user=user) + except: + pass - if not group: - syncgroup.delete() - update = True + if authserviceinfo: + update = False + for syncgroup in syncgroups: + group = groups.filter(name=syncgroup.groupname) - if update: - if authserviceinfo.jabber_username != "": - update_jabber_groups(user) - if authserviceinfo.mumble_username != "": - update_mumble_groups(user) - if authserviceinfo.forum_username != "": - update_forum_groups(user) + if not group: + syncgroup.delete() + update = True + + if update: + if authserviceinfo.jabber_username != "": + update_jabber_groups(user) + if authserviceinfo.mumble_username != "": + update_mumble_groups(user) + if authserviceinfo.forum_username != "": + update_forum_groups(user) @periodic_task(run_every=crontab(minute="*/1"))