mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-17 00:10:15 +02:00
Correct API key form validation errors.
If an individual field fails, its value gets removed from the cleaned_data dict, but the full form clean() method still gets called. As this form checks for api_id and api_key in the dict upon clean(), it would raise an unhandled KeyError
This commit is contained in:
parent
6c4e8ec2d1
commit
cced434a99
@ -28,7 +28,10 @@ class UpdateKeyForm(forms.Form):
|
|||||||
raise forms.ValidationError("API ID must be a number")
|
raise forms.ValidationError("API ID must be a number")
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super(UpdateKeyForm, self).clean()
|
if 'api_id' not in self.cleaned_data or 'api_key' not in self.cleaned_data:
|
||||||
|
# need to check if api_id and vcode in cleaned_data because
|
||||||
|
# if they fail, they get removed from the dict but this method still happens
|
||||||
|
return self.cleaned_data
|
||||||
|
|
||||||
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
|
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
|
||||||
logger.debug("UpdateKeyForm failed cleaning as API id %s already exists." % self.cleaned_data['api_id'])
|
logger.debug("UpdateKeyForm failed cleaning as API id %s already exists." % self.cleaned_data['api_id'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user