diff --git a/bda/management/commands/loadbdadevdata.py b/bda/management/commands/loadbdadevdata.py index a8851e3d..f348b310 100644 --- a/bda/management/commands/loadbdadevdata.py +++ b/bda/management/commands/loadbdadevdata.py @@ -77,7 +77,7 @@ class Command(MyBaseCommand): self.stdout.write("Inscription des utilisateurs aux tirages") ChoixSpectacle.objects.all().delete() choices = [] - for user in User.objects.filter(profile__is_cof=True): + for user in User.objects.filter(profile__cof__is_cof=True): for tirage in tirages: part, _ = Participant.objects.get_or_create( user=user, diff --git a/cof/autocomplete.py b/cof/autocomplete.py index 38dea4a2..2c05c701 100644 --- a/cof/autocomplete.py +++ b/cof/autocomplete.py @@ -26,14 +26,14 @@ def autocomplete(request): bits = q.split() queries['members'] = CofProfile.objects.filter(Q(is_cof=True)) - queries['users'] = User.objects.filter(Q(profile__is_cof=False)) + queries['users'] = User.objects.filter(Q(profile__cof__is_cof=False)) queries['clippers'] = Clipper.objects for bit in bits: queries['members'] = queries['members'].filter( - Q(user__first_name__icontains=bit) - | Q(user__last_name__icontains=bit) - | Q(user__username__icontains=bit) - | Q(login_clipper__icontains=bit)) + Q(profile__user__first_name__icontains=bit) + | Q(profile__user__last_name__icontains=bit) + | Q(profile__user__username__icontains=bit) + | Q(profile__login_clipper__icontains=bit)) queries['users'] = queries['users'].filter( Q(first_name__icontains=bit) | Q(last_name__icontains=bit) @@ -43,7 +43,7 @@ def autocomplete(request): | Q(username__icontains=bit)) queries['members'] = queries['members'].distinct() queries['users'] = queries['users'].distinct() - usernames = list(queries['members'].values_list('login_clipper', + usernames = list(queries['members'].values_list('profile__login_clipper', flat='True')) \ + list(queries['users'].values_list('profile__login_clipper', flat='True')) diff --git a/cof/decorators.py b/cof/decorators.py index d7e70608..a7ced8f7 100644 --- a/cof/decorators.py +++ b/cof/decorators.py @@ -9,8 +9,8 @@ from django_cas_ng.decorators import user_passes_test def is_cof(user): try: - profile = user.profile - return profile.is_cof + cofprofile = user.profile.cof + return cofprofile.is_cof except: return False @@ -21,8 +21,8 @@ cof_required_customdenied = user_passes_test(lambda u: is_cof(u), def is_buro(user): try: - profile = user.profile - return profile.is_buro + cofprofile = user.profile.cof + return cofprofile.is_buro except: return False diff --git a/cof/forms.py b/cof/forms.py index cf6652c7..a1ae7e1f 100644 --- a/cof/forms.py +++ b/cof/forms.py @@ -180,10 +180,6 @@ class EventStatusFilterForm(forms.Form): class RegistrationUserForm(forms.ModelForm): - def __init__(self, *args, **kw): - super(RegistrationUserForm, self).__init__(*args, **kw) - self.fields['username'].help_text = "" - def force_long_username(self): self.fields['username'].validators = [MinLengthValidator(9)] @@ -228,7 +224,6 @@ class RegistrationCofProfileForm(forms.ModelForm): fields = [ "num", "type_cotiz", "is_cof", "is_buro", "mailing", "mailing_bda", "mailing_bda_revente", - "petits_cours_accept", "petits_cours_remarques" ] def save(self, *args, **kw): diff --git a/cof/management/commands/loaddevdata.py b/cof/management/commands/loaddevdata.py index 4627c2d0..1525152c 100644 --- a/cof/management/commands/loaddevdata.py +++ b/cof/management/commands/loaddevdata.py @@ -19,6 +19,8 @@ from cof.petits_cours_models import ( PetitCoursAttributionCounter ) +from cof.models import CofProfile + # Où sont stockés les fichiers json DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data') @@ -47,8 +49,10 @@ class Command(MyBaseCommand): # Gaulois gaulois = self.from_json('gaulois.json', DATA_DIR, User) for user in gaulois: - user.profile.is_cof = True - user.profile.save() + CofProfile.objects.create( + profile=user.profile, + is_cof=True + ) # Romains self.from_json('romains.json', DATA_DIR, User) @@ -65,10 +69,12 @@ class Command(MyBaseCommand): root.set_password('root') root.is_staff = True root.is_superuser = True - root.profile.is_cof = True - root.profile.is_buro = True - root.profile.save() root.save() + CofProfile.objects.create( + profile=root.profile, + is_cof=True, + is_buro=True + ) # --- # Petits cours diff --git a/cof/templates/autocomplete_user.html b/cof/templates/autocomplete_user.html index 26411eee..f5802c5d 100644 --- a/cof/templates/autocomplete_user.html +++ b/cof/templates/autocomplete_user.html @@ -3,7 +3,7 @@ {% if members %}