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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user