From: Aleksander Ɓukasz Date: Fri, 8 Nov 2013 14:26:36 +0000 (+0100) Subject: Handle admin user without assigned questions X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/25da5b8159bea9655e1a1ed15cc414896a31a7eb?ds=inline;hp=a87786b8abce90bf32e1950b7fe2ea41ccf52ad5 Handle admin user without assigned questions --- diff --git a/wtem/admin.py b/wtem/admin.py index 5c495ec..47e0a77 100644 --- a/wtem/admin.py +++ b/wtem/admin.py @@ -13,8 +13,11 @@ from .middleware import get_current_request def get_user_exercises(user): - assignment = Assignment.objects.get(user = user) - return [e for e in exercises if e['id'] in assignment.exercises] + try: + assignment = Assignment.objects.get(user = user) + return [e for e in exercises if e['id'] in assignment.exercises] + except Assignment.DoesNotExist: + return [] readonly_fields = ('submitted_by', 'first_name', 'last_name', 'email', 'key', 'key_sent')