mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-02-02 01:18:13 +00:00
Fixed previous instance checking, check for PK as well as instance
This commit is contained in:
@@ -40,15 +40,15 @@ class EveAPIForm(forms.ModelForm):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
raise forms.ValidationError("Please provide a valid user ID.")
|
raise forms.ValidationError("Please provide a valid user ID.")
|
||||||
|
|
||||||
if not getattr(self, 'instance', None):
|
if self.instance and self.instance.pk:
|
||||||
|
if not int(self.cleaned_data['api_user_id']) == self.instance.api_user_id:
|
||||||
|
raise forms.ValidationError("You cannot change your API User ID")
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['api_user_id'])
|
eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['api_user_id'])
|
||||||
except EVEAccount.DoesNotExist:
|
except EVEAccount.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise forms.ValidationError("This API User ID is already registered")
|
raise forms.ValidationError("This API User ID is already registered")
|
||||||
else:
|
|
||||||
if not int(self.cleaned_data['api_user_id']) == self.instance.api_user_id:
|
|
||||||
raise forms.ValidationError("You cannot change your API User ID")
|
|
||||||
|
|
||||||
return self.cleaned_data['api_user_id']
|
return self.cleaned_data['api_user_id']
|
||||||
|
|||||||
Reference in New Issue
Block a user