Correction du dernier commit

This commit is contained in:
Martin Pépin 2016-08-24 16:26:43 +02:00
parent 9258f509ee
commit da07f34b51
2 changed files with 7 additions and 4 deletions

View file

@ -200,11 +200,11 @@ class UserProfileForm(forms.ModelForm):
class RegistrationUserForm(forms.ModelForm): class RegistrationUserForm(forms.ModelForm):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
new_user = kw.get('instance') is None
super(RegistrationUserForm, self).__init__(*args, **kw) super(RegistrationUserForm, self).__init__(*args, **kw)
self.fields['username'].help_text = "" self.fields['username'].help_text = ""
if new_user:
self.fields['username'].validators = [MinLengthValidator(9)] def force_long_username(self):
self.fields['username'].validators = [MinLengthValidator(9)]
class Meta: class Meta:
model = User model = User

View file

@ -364,6 +364,7 @@ def registration_form2(request, login_clipper=None, username=None):
elif not login_clipper: elif not login_clipper:
# new user # new user
user_form = RegistrationPassUserForm() user_form = RegistrationPassUserForm()
user_form.force_long_username()
profile_form = RegistrationProfileForm() profile_form = RegistrationProfileForm()
event_formset = EventFormset(events=events, prefix='events') event_formset = EventFormset(events=events, prefix='events')
return render(request, "registration_form.html", return render(request, "registration_form.html",
@ -405,7 +406,9 @@ def registration(request):
clipper = Clipper.objects.get(username=username) clipper = Clipper.objects.get(username=username)
login_clipper = clipper.username login_clipper = clipper.username
except Clipper.DoesNotExist: except Clipper.DoesNotExist:
pass user_form.force_long_username()
else:
user_form.force_long_username()
# ----- # -----
# Validation des formulaires # Validation des formulaires