Clipper logins may be > 8 characters
This commit is contained in:
parent
387edd2fd5
commit
51f4bf3fb5
|
@ -10,7 +10,6 @@ from django.contrib.auth.models import User
|
||||||
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
||||||
from django.forms.formsets import BaseFormSet, formset_factory
|
from django.forms.formsets import BaseFormSet, formset_factory
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
from django.core.validators import MinLengthValidator
|
|
||||||
|
|
||||||
from gestioncof.models import CofProfile, EventCommentValue, \
|
from gestioncof.models import CofProfile, EventCommentValue, \
|
||||||
CalendarSubscription, Club
|
CalendarSubscription, Club
|
||||||
|
@ -203,9 +202,6 @@ class RegistrationUserForm(forms.ModelForm):
|
||||||
super(RegistrationUserForm, self).__init__(*args, **kw)
|
super(RegistrationUserForm, self).__init__(*args, **kw)
|
||||||
self.fields['username'].help_text = ""
|
self.fields['username'].help_text = ""
|
||||||
|
|
||||||
def force_long_username(self):
|
|
||||||
self.fields['username'].validators = [MinLengthValidator(9)]
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ("username", "first_name", "last_name", "email")
|
fields = ("username", "first_name", "last_name", "email")
|
||||||
|
|
19
gestioncof/migrations/0011_longer_clippers.py
Normal file
19
gestioncof/migrations/0011_longer_clippers.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('gestioncof', '0010_delete_custommail'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cofprofile',
|
||||||
|
name='login_clipper',
|
||||||
|
field=models.CharField(verbose_name='Login clipper', blank=True, max_length=32),
|
||||||
|
),
|
||||||
|
]
|
|
@ -38,7 +38,9 @@ TYPE_COMMENT_FIELD = (
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class CofProfile(models.Model):
|
class CofProfile(models.Model):
|
||||||
user = models.OneToOneField(User, related_name="profile")
|
user = models.OneToOneField(User, related_name="profile")
|
||||||
login_clipper = models.CharField("Login clipper", max_length=8, blank=True)
|
login_clipper = models.CharField(
|
||||||
|
"Login clipper", max_length=32, blank=True
|
||||||
|
)
|
||||||
is_cof = models.BooleanField("Membre du COF", default=False)
|
is_cof = models.BooleanField("Membre du COF", default=False)
|
||||||
num = models.IntegerField("Numéro d'adhérent", blank=True, default=0)
|
num = models.IntegerField("Numéro d'adhérent", blank=True, default=0)
|
||||||
phone = models.CharField("Téléphone", max_length=20, blank=True)
|
phone = models.CharField("Téléphone", max_length=20, blank=True)
|
||||||
|
|
|
@ -384,7 +384,6 @@ 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')
|
||||||
clubs_form = ClubsForm()
|
clubs_form = ClubsForm()
|
||||||
|
@ -427,12 +426,10 @@ def registration(request):
|
||||||
user_form = RegistrationUserForm(request_dict, instance=member)
|
user_form = RegistrationUserForm(request_dict, instance=member)
|
||||||
if member.profile.login_clipper:
|
if member.profile.login_clipper:
|
||||||
login_clipper = member.profile.login_clipper
|
login_clipper = member.profile.login_clipper
|
||||||
else:
|
|
||||||
user_form.force_long_username()
|
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
user_form.force_long_username()
|
pass
|
||||||
else:
|
else:
|
||||||
user_form.force_long_username()
|
pass
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Validation des formulaires
|
# Validation des formulaires
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinLengthValidator
|
|
||||||
from django.contrib.auth.models import User, Group, Permission
|
from django.contrib.auth.models import User, Group, Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.forms import modelformset_factory
|
from django.forms import modelformset_factory
|
||||||
|
@ -105,14 +104,8 @@ class CofRestrictForm(CofForm):
|
||||||
class Meta(CofForm.Meta):
|
class Meta(CofForm.Meta):
|
||||||
fields = ['departement']
|
fields = ['departement']
|
||||||
|
|
||||||
class UserForm(forms.ModelForm):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
from_clipper = kwargs.pop('from_clipper', False)
|
|
||||||
new_user = kwargs.get('instance') is None and not from_clipper
|
|
||||||
super(UserForm, self).__init__(*args, **kwargs)
|
|
||||||
if new_user:
|
|
||||||
self.fields['username'].validators = [MinLengthValidator(9)]
|
|
||||||
|
|
||||||
|
class UserForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['username', 'first_name', 'last_name', 'email']
|
fields = ['username', 'first_name', 'last_name', 'email']
|
||||||
|
@ -120,6 +113,7 @@ class UserForm(forms.ModelForm):
|
||||||
'username': ''
|
'username': ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class UserRestrictForm(UserForm):
|
class UserRestrictForm(UserForm):
|
||||||
class Meta(UserForm.Meta):
|
class Meta(UserForm.Meta):
|
||||||
fields = ['first_name', 'last_name']
|
fields = ['first_name', 'last_name']
|
||||||
|
|
Loading…
Reference in a new issue