From 288ccc67057971dbd65102be3b56f448735797cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 22 May 2020 07:08:18 +0200 Subject: [PATCH] Fix creation of LTIProviderConfig object in admin When attempting to create a "Provider Configuration (LTI)" object in the django admin, the following 500 error was being triggered: "Either an icon class or an icon image must be given (but not both)" This was caused by the `clean()` method of the mother class (OAuth2ProviderConfig) which checked whether at least the icon_class XOR icon_list attribute was well defined. In the case of the LTIProviderConfig objects it isn't, but that's ok because this object is not meant to be displayed in the login form. To resolve this issue, we modify the `clean()` method to ensure that at most icon_class or icon_image is set. Alternatively, we could have set `visible = False` and then dropped the `visible` column from the database, but it was deemed too risky. unused. Close CRI-205. --- common/djangoapps/third_party_auth/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/third_party_auth/models.py b/common/djangoapps/third_party_auth/models.py index 07c1165cbc..23ef8edbed 100644 --- a/common/djangoapps/third_party_auth/models.py +++ b/common/djangoapps/third_party_auth/models.py @@ -223,9 +223,9 @@ class ProviderConfig(ConfigurationModel): abstract = True def clean(self): - """ Ensure that either `icon_class` or `icon_image` is set """ + """ Ensure that at most `icon_class` or `icon_image` is set """ super(ProviderConfig, self).clean() - if bool(self.icon_class) == bool(self.icon_image): + if bool(self.icon_class) and bool(self.icon_image): raise ValidationError('Either an icon class or an icon image must be given (but not both)') @property