diff --git a/lms/djangoapps/licenses/models.py b/lms/djangoapps/licenses/models.py index d259892..06f777f 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