Commit 00e235c7 by Őry Máté

school: log shib logins

parent 448ef865
...@@ -62,7 +62,8 @@ def login(request): ...@@ -62,7 +62,8 @@ def login(request):
for c in attended: for c in attended:
try: try:
co = Course.objects.get(code=c) co = Course.objects.get(code=c)
except: except Exception as e:
logger.warning("Django could not get Course %s: %s" % (c, e))
continue continue
g = co.get_or_create_default_group() g = co.get_or_create_default_group()
if p.course_groups.filter(semester=sem, course=co).count() == 0: if p.course_groups.filter(semester=sem, course=co).count() == 0:
...@@ -70,7 +71,9 @@ def login(request): ...@@ -70,7 +71,9 @@ def login(request):
g.members.add(p) g.members.add(p)
g.save() g.save()
messages.info(request, _('Course "%s" added.') % g.course) messages.info(request, _('Course "%s" added.') % g.course)
logger.warning('Django Course "%s" added.' % g.course)
except Exception as e: except Exception as e:
messages.error(request, _('Failed to add course "%s".') % g.course)
logger.warning("Django ex %s" % e) logger.warning("Django ex %s" % e)
except ValidationError as e: except ValidationError as e:
logger.warning("Django ex4 %s" % e) logger.warning("Django ex4 %s" % e)
...@@ -83,13 +86,14 @@ def login(request): ...@@ -83,13 +86,14 @@ def login(request):
for c in held: for c in held:
co, created = Course.objects.get_or_create(code=c) co, created = Course.objects.get_or_create(code=c)
if created: if created:
logger.warning("django Course %s created" % c) logger.warning("Django Course %s created" % c)
g = co.get_or_create_default_group() g = co.get_or_create_default_group()
try: try:
co.owners.add(p) co.owners.add(p)
g.owners.add(p) g.owners.add(p)
messages.info(request, _('Course "%s" ownership added.') % g.course) messages.info(request, _('Course "%s" ownership added.') % g.course)
except Exception as e: except Exception as e:
messages.error(request, _('Failed to add course "%s" ownership.') % g.course)
logger.warning("Django ex %s" % e) logger.warning("Django ex %s" % e)
co.save() co.save()
g.save() g.save()
...@@ -107,9 +111,9 @@ def login(request): ...@@ -107,9 +111,9 @@ def login(request):
g = Group.objects.filter(name=a) g = Group.objects.filter(name=a)
g.members.add(p) g.members.add(p)
g.save() g.save()
messages.info(request, _('Course "%s" added.') % g.course) logger.warning("Django affiliation %s added to %s" % (a, p))
except: except:
pass logger.warning("Django FAIL affiliation %s added to %s" % (a, p))
user.save() user.save()
p.save() p.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment