Add fix for users with multiple licenses

This commit is contained in:
Carlos Andrés Rocha
2012-10-22 10:25:49 -04:00
parent 853051bcc0
commit 3784c3ce18

View File

@@ -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