Check the input is a valid integer

This commit is contained in:
2011-02-16 16:40:44 +00:00
parent 3724b30d99
commit d32b15ed64

View File

@@ -26,6 +26,11 @@ class EveAPIForm(forms.Form):
if not 'user_id' in self.cleaned_data or self.cleaned_data['user_id'] == '': if not 'user_id' in self.cleaned_data or self.cleaned_data['user_id'] == '':
raise forms.ValidationError("Please provide a valid User ID") raise forms.ValidationError("Please provide a valid User ID")
try:
int(self.cleaned_data['user_id'])
except ValueError:
raise forms.ValidationError("Please provide a valid user ID.")
try: try:
eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['user_id']) eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['user_id'])
except EVEAccount.DoesNotExist: except EVEAccount.DoesNotExist: