diff --git a/users/admin.py b/users/admin.py index 0c71064a..e8472acd 100644 --- a/users/admin.py +++ b/users/admin.py @@ -42,7 +42,6 @@ from .forms import ServiceUserChangeForm, ServiceUserCreationForm class UserAdmin(admin.ModelAdmin): """Administration d'un user""" list_display = ( - 'name', 'surname', 'pseudo', 'room', @@ -51,7 +50,7 @@ class UserAdmin(admin.ModelAdmin): 'shell', 'state' ) - search_fields = ('name', 'surname', 'pseudo', 'room') + search_fields = ('surname', 'pseudo', 'room') class LdapUserAdmin(admin.ModelAdmin): @@ -127,7 +126,6 @@ class UserAdmin(VersionAdmin, BaseUserAdmin): # that reference specific fields on auth.User. list_display = ( 'pseudo', - 'name', 'surname', 'email', 'school', @@ -142,7 +140,7 @@ class UserAdmin(VersionAdmin, BaseUserAdmin): 'Personal info', { 'fields': - ('name', 'surname', 'email', 'school', 'shell', 'uid_number') + ('surname', 'email', 'school', 'shell', 'uid_number') } ), ('Permissions', {'fields': ('is_admin', )}), @@ -156,7 +154,6 @@ class UserAdmin(VersionAdmin, BaseUserAdmin): 'classes': ('wide',), 'fields': ( 'pseudo', - 'name', 'surname', 'email', 'school', diff --git a/users/forms.py b/users/forms.py index 93ef35b5..9b0b1fb6 100644 --- a/users/forms.py +++ b/users/forms.py @@ -41,7 +41,7 @@ from django.utils import timezone from preferences.models import OptionalUser from .models import User, ServiceUser, Right, School, ListRight, Whitelist -from .models import Ban, remove_user_room +from .models import Ban, remove_user_room, Adherent, Club NOW = timezone.now() @@ -100,7 +100,7 @@ class UserCreationForm(forms.ModelForm): class Meta: model = User - fields = ('pseudo', 'name', 'surname', 'email') + fields = ('pseudo', 'surname', 'email') def clean_password2(self): """Verifie que password1 et 2 sont identiques""" @@ -180,7 +180,7 @@ class UserChangeForm(forms.ModelForm): class Meta: model = User - fields = ('pseudo', 'password', 'name', 'surname', 'email') + fields = ('pseudo', 'password', 'surname', 'email') def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) @@ -268,7 +268,7 @@ class BaseInfoForm(ModelForm): self.fields['school'].empty_label = "Séléctionner un établissement" class Meta: - model = User + model = Adherent fields = [ 'name', 'surname', diff --git a/users/migrations/0057_auto_20171023_0301.py b/users/migrations/0057_auto_20171023_0301.py new file mode 100644 index 00000000..d8a02c54 --- /dev/null +++ b/users/migrations/0057_auto_20171023_0301.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-23 01:01 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0056_auto_20171015_2033'), + ] + + operations = [ + migrations.CreateModel( + name='Adherent', + fields=[ + ('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), + ('usname', models.CharField(max_length=255)), + ], + options={ + 'abstract': False, + }, + bases=('users.user',), + ), + migrations.CreateModel( + name='Club', + fields=[ + ('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'abstract': False, + }, + bases=('users.user',), + ), + migrations.RunSQL("insert into users_adherent (user_ptr_id, usname) select id, name from users_user", reverse_sql="insert into users_user (name) select usname from users_adherent"), + migrations.RemoveField( + model_name='user', + name='name', + ), + migrations.RenameField( + model_name='adherent', + old_name='usname', + new_name='name', + ), +] diff --git a/users/models.py b/users/models.py index 550bc770..64b8fe03 100644 --- a/users/models.py +++ b/users/models.py @@ -207,7 +207,6 @@ class User(AbstractBaseUser): """Renvoie un uid libre""" return get_fresh_user_uid() - name = models.CharField(max_length=255) surname = models.CharField(max_length=255) pseudo = models.CharField( max_length=32, @@ -683,6 +682,15 @@ class User(AbstractBaseUser): return self.pseudo +class Adherent(User): + name = models.CharField(max_length=255) + pass + + +class Club(User): + pass + + @receiver(post_save, sender=User) def user_post_save(sender, **kwargs): """ Synchronisation post_save : envoie le mail de bienvenue si creation diff --git a/users/views.py b/users/views.py index d8d4be62..bfe2ee59 100644 --- a/users/views.py +++ b/users/views.py @@ -53,7 +53,7 @@ from reversion.models import Version from reversion import revisions as reversion from users.serializers import MailSerializer from users.models import User, Right, Ban, Whitelist, School, ListRight -from users.models import Request, ServiceUser +from users.models import Request, ServiceUser, Adherent, Club from users.forms import DelRightForm, BanForm, WhitelistForm, DelSchoolForm from users.forms import DelListRightForm, NewListRightForm from users.forms import InfoForm, BaseInfoForm, StateForm