[damned-lies] Imported ValidationError from django.core.exceptions
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Imported ValidationError from django.core.exceptions
- Date: Fri, 3 Mar 2017 18:26:42 +0000 (UTC)
commit 060c20873673f7d96619a5218842f09ae4f24850
Author: Claude Paroz <claude 2xlibre net>
Date: Fri Mar 3 18:15:48 2017 +0100
Imported ValidationError from django.core.exceptions
people/forms.py | 17 +++++++++--------
stats/forms.py | 4 +++-
vertimus/forms.py | 15 ++++++++-------
3 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/people/forms.py b/people/forms.py
index abf819c..06f1f4b 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -5,6 +5,7 @@ from urllib.request import urlopen
from django import forms
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
+from django.core.exceptions import ValidationError
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.utils.encoding import force_bytes
@@ -33,7 +34,7 @@ class RegistrationForm(forms.Form):
Person.objects.get(username__iexact=self.cleaned_data['username'])
except Person.DoesNotExist:
return self.cleaned_data['username']
- raise forms.ValidationError(_('This username is already taken. Please choose another.'))
+ raise ValidationError(_('This username is already taken. Please choose another.'))
def clean_openid_url(self):
""" Check openid url is not already linked to any existing user """
@@ -43,7 +44,7 @@ class RegistrationForm(forms.Form):
UserOpenID.objects.get(claimed_id=self.cleaned_data['openid_url'])
except UserOpenID.DoesNotExist:
return self.cleaned_data['openid_url']
- raise forms.ValidationError(_('This OpenID URL is already taken by a registered user'))
+ raise ValidationError(_('This OpenID URL is already taken by a registered user'))
else:
return self.cleaned_data['openid_url']
@@ -53,10 +54,10 @@ class RegistrationForm(forms.Form):
password2 = cleaned_data.get('password2')
openid_url = cleaned_data.get('openid_url')
if not password1 and not openid_url:
- raise forms.ValidationError(_('You must either provide an OpenID or a password'))
+ raise ValidationError(_('You must either provide an OpenID or a password'))
if password1 and password1 != password2:
- raise forms.ValidationError(_('The passwords do not match'))
+ raise ValidationError(_('The passwords do not match'))
return cleaned_data
def save(self, request):
@@ -101,7 +102,7 @@ class DetailForm(forms.ModelForm):
return
size = get_image_size(url)
if size[0]>100 or size[1]>100:
- raise forms.ValidationError(_("Image too high or too wide (%(width)d×%(height)d, maximum is
100×100 pixels)") % {
+ raise ValidationError(_("Image too high or too wide (%(width)d×%(height)d, maximum is 100×100
pixels)") % {
'width': size[0], 'height': size[1]})
return url
@@ -119,7 +120,7 @@ def get_image_size(url):
try:
im_file = urlopen(url)
except (IOError, InvalidURL, EOFError, ValueError):
- raise forms.ValidationError(_("The URL you provided is not valid"))
+ raise ValidationError(_("The URL you provided is not valid"))
size = None
p = ImageFile.Parser()
try:
@@ -132,9 +133,9 @@ def get_image_size(url):
size = p.image.size
break
except Exception as e:
- raise forms.ValidationError("Sorry, an error occurred while trying to get image size (%s)" % str(e))
+ raise ValidationError("Sorry, an error occurred while trying to get image size (%s)" % str(e))
finally:
im_file.close()
if not size:
- raise forms.ValidationError(_("The URL you provided seems not to correspond to a valid image"))
+ raise ValidationError(_("The URL you provided seems not to correspond to a valid image"))
return size
diff --git a/stats/forms.py b/stats/forms.py
index 2c00409..1ec5828 100644
--- a/stats/forms.py
+++ b/stats/forms.py
@@ -1,4 +1,5 @@
from django import forms
+from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from stats.models import Branch, Category, CategoryName, Release
@@ -11,6 +12,7 @@ class ReleaseField(forms.ModelChoiceField):
if 'label' in kwargs:
self.is_branch = True
+
class ModuleBranchForm(forms.Form):
def __init__(self, module, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -60,7 +62,7 @@ class ModuleBranchForm(forms.Form):
and cleaned_data[field_name[:-4]] is not None):
self.add_error(
field_name,
- forms.ValidationError(_("You have to provide a category when a version is specified."))
+ ValidationError(_("You have to provide a category when a version is specified."))
)
if cleaned_data['new_branch']:
try:
diff --git a/vertimus/forms.py b/vertimus/forms.py
index 90e3571..ade8962 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -1,6 +1,7 @@
import os
from django import forms
+from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext, ugettext_lazy as _
@@ -81,33 +82,33 @@ class ActionForm(forms.Form):
if data:
ext = os.path.splitext(data.name)[1]
if ext not in ('.po', '.gz', '.bz2', '.png'):
- raise forms.ValidationError(_("Only files with extension .po, .gz, .bz2 or .png are
admitted."))
+ raise ValidationError(_("Only files with extension .po, .gz, .bz2 or .png are admitted."))
# If this is a .po file, check validity (msgfmt)
if ext == '.po':
res = po_file_stats(data)
if res['errors']:
- raise forms.ValidationError(_(".po file does not pass “msgfmt -vc”. Please correct the
file and try again."))
+ raise ValidationError(_(".po file does not pass “msgfmt -vc”. Please correct the file
and try again."))
return data
def clean(self):
cleaned_data = self.cleaned_data
action_code = cleaned_data.get('action')
if action_code is None:
- raise forms.ValidationError(_("Invalid action. Someone probably posted another action just
before you."))
+ raise ValidationError(_("Invalid action. Someone probably posted another action just before
you."))
comment = cleaned_data.get('comment')
file = cleaned_data.get('file')
action = Action.new_by_name(action_code, comment=comment, file=file)
if action.comment_is_required and not comment:
- raise forms.ValidationError(_("A comment is needed for this action."))
+ raise ValidationError(_("A comment is needed for this action."))
if self.is_valid() and action.arg_is_required and not comment and not file:
- raise forms.ValidationError(_("A comment or a file is needed for this action."))
+ raise ValidationError(_("A comment or a file is needed for this action."))
if self.is_valid() and action.file_is_required and not file:
- raise forms.ValidationError(_("A file is needed for this action."))
+ raise ValidationError(_("A file is needed for this action."))
if action.file_is_prohibited and file:
- raise forms.ValidationError(_("Please, don’t send a file with a “Reserve” action."))
+ raise ValidationError(_("Please, don’t send a file with a “Reserve” action."))
return cleaned_data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]