From 3784c3ce18be0705596c666683a3d53a2e971cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s=20Rocha?= Date: Mon, 22 Oct 2012 10:25:49 -0400 Subject: [PATCH] Add fix for users with multiple licenses --- lms/djangoapps/licenses/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/licenses/models.py b/lms/djangoapps/licenses/models.py index d259892f5d..06f777f611 100644 --- a/lms/djangoapps/licenses/models.py +++ b/lms/djangoapps/licenses/models.py @@ -42,7 +42,10 @@ def get_courses_licenses(user, courses): def get_license(user, software): try: - license = UserLicense.objects.get(user=user, software=software) + # TODO: temporary fix for when somehow a user got more that one license. + # The proper fix should use Meta.unique_together in the UserLicense model. + licenses = UserLicense.objects.filter(user=user, software=software) + license = licenses[0] if licenses else None except UserLicense.DoesNotExist: license = None