Fixed exception thrown in celery

This commit is contained in:
Raynaldo Rivera 2014-10-12 11:03:32 -07:00
parent 534eb460e1
commit 0256feeceb
2 changed files with 49 additions and 35 deletions

View File

@ -144,7 +144,7 @@ DEFAULT_ALLIANCE_GROUP = 'AllianceMember'
# ALLIANCE INFO # ALLIANCE INFO
ALLIANCE_ID = '0' ALLIANCE_ID = '0'
ALLIANCE_NAME = 'Alliance Name' ALLIANCE_NAME = 'SomeAllianceName'
# Jabber Prosody Info # Jabber Prosody Info
JABBER_URL = "@someaddress.com" JABBER_URL = "@someaddress.com"

View File

@ -50,47 +50,61 @@ def update_forum_groups(user):
def add_to_databases(user, groups, syncgroups): def add_to_databases(user, groups, syncgroups):
authserviceinfo = AuthServicesInfo.objects.get(user=user)
update = False authserviceinfo = None
for group in groups: try:
syncgroup = syncgroups.filter(groupname=group.name) authserviceinfo = AuthServicesInfo.objects.get(user=user)
if not syncgroup: except:
# gotta create group pass
# create syncgroup
# create service groups
synccache = SyncGroupCache()
synccache.groupname = group.name
synccache.user = user
synccache.save()
update = True
if update: if authserviceinfo:
if authserviceinfo.jabber_username != "": authserviceinfo = AuthServicesInfo.objects.get(user=user)
update_jabber_groups(user)
if authserviceinfo.mumble_username != "": update = False
update_mumble_groups(user) for group in groups:
if authserviceinfo.forum_username != "": syncgroup = syncgroups.filter(groupname=group.name)
update_forum_groups(user) 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): def remove_from_databases(user, groups, syncgroups):
authserviceinfo = AuthServicesInfo.objects.get(user=user) authserviceinfo = None
update = False try:
for syncgroup in syncgroups: authserviceinfo = AuthServicesInfo.objects.get(user=user)
group = groups.filter(name=syncgroup.groupname) except:
pass
if not group: if authserviceinfo:
syncgroup.delete() update = False
update = True for syncgroup in syncgroups:
group = groups.filter(name=syncgroup.groupname)
if update: if not group:
if authserviceinfo.jabber_username != "": syncgroup.delete()
update_jabber_groups(user) update = True
if authserviceinfo.mumble_username != "":
update_mumble_groups(user) if update:
if authserviceinfo.forum_username != "": if authserviceinfo.jabber_username != "":
update_forum_groups(user) 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")) @periodic_task(run_every=crontab(minute="*/1"))