1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-11-27 01:27:10 +00:00

Rename surname to last_name

This commit is contained in:
Alexandre Iooss 2019-08-02 21:47:54 +02:00
parent e82053d16f
commit 3509491076
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
13 changed files with 137 additions and 36 deletions

View File

@ -41,20 +41,20 @@ def search_result(search, type, request):
if request.user.has_perms(('perm',)): if request.user.has_perms(('perm',)):
query = Q(user__username__icontains=search) | Q(user__name__icontains=search) | Q( query = Q(user__username__icontains=search) | Q(user__name__icontains=search) | Q(
user__surname__icontains=search) user__last_name__icontains=search)
else: else:
query = (Q(user__username__icontains=search) | Q(user__name__icontains=search) | Q( query = (Q(user__username__icontains=search) | Q(user__name__icontains=search) | Q(
user__surname__icontains=search)) & Q(user=request.user) user__last_name__icontains=search)) & Q(user=request.user)
for i in aff: for i in aff:
if i == '0': if i == '0':
query_user_list = Q(username__icontains=search) | Q(name__icontains=search) | Q( query_user_list = Q(username__icontains=search) | Q(name__icontains=search) | Q(
surname__icontains=search) & query1 last_name__icontains=search) & query1
if request.user.has_perms(('perm',)): if request.user.has_perms(('perm',)):
recherche['users_list'] = User.objects.filter(query_user_list).order_by('surname') recherche['users_list'] = User.objects.filter(query_user_list).order_by('last_name')
else: else:
recherche['users_list'] = User.objects.filter(query_user_list & Q(id=request.user.id)).order_by( recherche['users_list'] = User.objects.filter(query_user_list & Q(id=request.user.id)).order_by(
'surname') 'last_name')
if i == '1': if i == '1':
recherche['emprunts_list'] = Emprunt.objects.filter(query & date_query).order_by('date_emprunt').reverse() recherche['emprunts_list'] = Emprunt.objects.filter(query & date_query).order_by('date_emprunt').reverse()
if i == '2': if i == '2':
@ -63,7 +63,7 @@ def search_result(search, type, request):
if i == '3': if i == '3':
recherche['jeux_list'] = Jeu.objects.filter( recherche['jeux_list'] = Jeu.objects.filter(
Q(nom__icontains=search) | Q(proprietaire__username__icontains=search) | Q( Q(nom__icontains=search) | Q(proprietaire__username__icontains=search) | Q(
proprietaire__name__icontains=search) | Q(proprietaire__surname__icontains=search)) proprietaire__name__icontains=search) | Q(proprietaire__last_name__icontains=search))
for r in recherche: for r in recherche:
if recherche[r] is not None: if recherche[r] is not None:

View File

@ -111,7 +111,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="panel panel-default"> <div class="panel panel-default">
{% if request_user.is_authenticated %} {% if request_user.is_authenticated %}
<div class="panel-heading"> <div class="panel-heading">
<h4>{{ request_user.name }} {{ request_user.surname }}</h4> <h4>{{ request_user.name }} {{ request_user.last_name }}</h4>
</div> </div>
<table class="table"> <table class="table">
<tr> <tr>
@ -120,7 +120,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr> </tr>
<tr> <tr>
<th scope="row">Nom</th> <th scope="row">Nom</th>
<td class="text-right">{{ request_user.surname }}</td> <td class="text-right">{{ request_user.last_name }}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Prénom</th> <th scope="row">Prénom</th>

View File

@ -39,11 +39,11 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
# The fields to be used in displaying the User model. # The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin # These override the definitions on the base UserAdmin
# that reference specific fields on auth.User. # that reference specific fields on auth.User.
list_display = ('username', 'name', 'surname', 'email', 'is_admin') list_display = ('username', 'name', 'last_name', 'email', 'is_admin')
list_filter = () list_filter = ()
fieldsets = ( fieldsets = (
(None, {'fields': ('username', 'password')}), (None, {'fields': ('username', 'password')}),
('Personal info', {'fields': ('name', 'surname', 'email')}), ('Personal info', {'fields': ('name', 'last_name', 'email')}),
('Permissions', {'fields': ('is_admin',)}), ('Permissions', {'fields': ('is_admin',)}),
) )
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
@ -51,7 +51,7 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
add_fieldsets = ( add_fieldsets = (
(None, { (None, {
'classes': ('wide',), 'classes': ('wide',),
'fields': ('username', 'name', 'surname', 'email', 'is_admin', 'password1', 'password2')} 'fields': ('username', 'name', 'last_name', 'email', 'is_admin', 'password1', 'password2')}
), ),
) )
search_fields = ('username',) search_fields = ('username',)

View File

@ -28,7 +28,7 @@ class UserCreationForm(forms.ModelForm):
class Meta: class Meta:
model = User model = User
fields = ('username', 'name', 'surname', 'email') fields = ('username', 'name', 'last_name', 'email')
def clean_password2(self): def clean_password2(self):
# Check that the two password entries match # Check that the two password entries match
@ -57,7 +57,7 @@ class UserChangeForm(forms.ModelForm):
class Meta: class Meta:
model = User model = User
fields = ('username', 'password', 'name', 'surname', 'email') fields = ('username', 'password', 'name', 'last_name', 'email')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(UserChangeForm, self).__init__(*args, **kwargs) super(UserChangeForm, self).__init__(*args, **kwargs)
@ -83,7 +83,7 @@ class BaseInfoForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(BaseInfoForm, self).__init__(*args, **kwargs) super(BaseInfoForm, self).__init__(*args, **kwargs)
self.fields['name'].label = 'Prénom' self.fields['name'].label = 'Prénom'
self.fields['surname'].label = 'Nom' self.fields['last_name'].label = 'Nom'
# self.fields['comment'].label = 'Commentaire' # self.fields['comment'].label = 'Commentaire'
class Meta: class Meta:
@ -91,7 +91,7 @@ class BaseInfoForm(ModelForm):
fields = [ fields = [
'name', 'name',
'username', 'username',
'surname', 'last_name',
'email', 'email',
'telephone', 'telephone',
'adresse', 'adresse',
@ -103,7 +103,7 @@ class InfoForm(BaseInfoForm):
fields = [ fields = [
'name', 'name',
'username', 'username',
'surname', 'last_name',
'email', 'email',
'telephone', 'telephone',
'adresse', 'adresse',

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-02 19:43
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0014_auto_20190802_2126'),
]
operations = [
migrations.RenameField(
model_name='user',
old_name='surname',
new_name='last_name',
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-02 19:43
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0015_auto_20190802_2143'),
]
operations = [
migrations.AlterField(
model_name='user',
name='last_name',
field=models.CharField(blank=True, max_length=30, verbose_name='last name'),
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-02 19:44
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0016_auto_20190802_2143'),
]
operations = [
migrations.AlterField(
model_name='user',
name='email',
field=models.EmailField(blank=True, max_length=254, verbose_name='email address'),
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-02 19:44
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0017_auto_20190802_2144'),
]
operations = [
migrations.RenameField(
model_name='user',
old_name='registered',
new_name='date_joined',
),
]

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-02 19:46
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('users', '0018_auto_20190802_2144'),
]
operations = [
migrations.AlterField(
model_name='user',
name='date_joined',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined'),
),
]

View File

@ -17,7 +17,7 @@ from med.settings import MAX_EMPRUNT, REQ_EXPIRE_HRS
class UserManager(BaseUserManager): class UserManager(BaseUserManager):
use_in_migrations = True use_in_migrations = True
def _create_user(self, username, name, surname, email, password=None, su=False): def _create_user(self, username, name, last_name, email, password=None, su=False):
""" """
Creates and saves a User with the given username, email and password. Creates and saves a User with the given username, email and password.
""" """
@ -28,7 +28,7 @@ class UserManager(BaseUserManager):
user = self.model( user = self.model(
username=username, username=username,
name=name, name=name,
surname=surname, last_name=last_name,
email=email, email=email,
) )
@ -38,28 +38,27 @@ class UserManager(BaseUserManager):
user.make_admin() user.make_admin()
return user return user
def create_user(self, username, name, surname, email, password=None): def create_user(self, username, name, last_name, email, password=None):
""" """
Creates and saves a User with the given username, name, surname, email, Creates and saves a User with the given username, name, last_name, email,
and password. and password.
""" """
return self._create_user(username, name, surname, email, password, False) return self._create_user(username, name, last_name, email, password, False)
def create_superuser(self, username, name, surname, email, password): def create_superuser(self, username, name, last_name, email, password):
""" """
Creates and saves a superuser with the given username, name, surname, Creates and saves a superuser with the given username, name, last_name,
email, and password. email, and password.
""" """
return self._create_user(username, name, surname, email, password, True) return self._create_user(username, name, last_name, email, password, True)
class User(AbstractBaseUser): class User(AbstractBaseUser):
username_validator = UnicodeUsernameValidator() if six.PY3 else ASCIIUsernameValidator() username_validator = UnicodeUsernameValidator() if six.PY3 else ASCIIUsernameValidator()
PRETTY_NAME = "Utilisateurs"
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
surname = models.CharField(max_length=255) last_name = models.CharField(_('last name'), max_length=30, blank=True)
email = models.EmailField() email = models.EmailField(_('email address'), blank=True)
telephone = models.CharField(max_length=15, null=True, blank=True) telephone = models.CharField(max_length=15, null=True, blank=True)
adresse = models.CharField(max_length=255, null=True, blank=True) adresse = models.CharField(max_length=255, null=True, blank=True)
maxemprunt = models.IntegerField(default=MAX_EMPRUNT, help_text="Maximum d'emprunts autorisés") maxemprunt = models.IntegerField(default=MAX_EMPRUNT, help_text="Maximum d'emprunts autorisés")
@ -87,13 +86,14 @@ class User(AbstractBaseUser):
'Unselect this instead of deleting accounts.' 'Unselect this instead of deleting accounts.'
), ),
) )
registered = models.DateTimeField(auto_now_add=True) date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['name', 'surname', 'email']
objects = UserManager() objects = UserManager()
EMAIL_FIELD = 'email'
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['name', 'last_name', 'email']
@property @property
def is_admin(self): def is_admin(self):
try: try:
@ -118,7 +118,7 @@ class User(AbstractBaseUser):
return False return False
def get_full_name(self): def get_full_name(self):
return '%s %s' % (self.name, self.surname) return '%s %s' % (self.name, self.last_name)
def get_short_name(self): def get_short_name(self):
return self.name return self.name

View File

@ -41,7 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for user in users_list %} {% for user in users_list %}
<tr> <tr>
<td>{{ user.name }}</td> <td>{{ user.name }}</td>
<td>{{ user.surname }}</td> <td>{{ user.last_name }}</td>
<td>{{ user.username }}</td> <td>{{ user.username }}</td>
<td>{{ user.email }}</td> <td>{{ user.email }}</td>
<td>{{ user.maxemprunt }}</td> <td>{{ user.maxemprunt }}</td>

View File

@ -61,7 +61,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>Prénom</th> <th>Prénom</th>
<td>{{ user.name }}</td> <td>{{ user.name }}</td>
<th>Nom</th> <th>Nom</th>
<td>{{ user.surname }}</td> <td>{{ user.last_name }}</td>
</tr> </tr>
<tr> <tr>
<th>Pseudo</th> <th>Pseudo</th>
@ -73,7 +73,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>Commentaire</th> <th>Commentaire</th>
<td>{{ user.comment }}</td> <td>{{ user.comment }}</td>
<th>Date d'inscription</th> <th>Date d'inscription</th>
<td>{{ user.registered }}</td> <td>{{ user.date_joined }}</td>
</tr> </tr>
<tr> <tr>
<th>Adresse</th> <th>Adresse</th>

View File

@ -52,7 +52,7 @@ def reset_passwd_mail(req, request):
""" Prend en argument un request, envoie un mail de réinitialisation de mot de pass """ """ Prend en argument un request, envoie un mail de réinitialisation de mot de pass """
t = loader.get_template('users/email_passwd_request') t = loader.get_template('users/email_passwd_request')
c = { c = {
'name': str(req.user.name) + ' ' + str(req.user.surname), 'name': str(req.user.name) + ' ' + str(req.user.last_name),
'asso': ASSO_NAME, 'asso': ASSO_NAME,
'asso_mail': ASSO_EMAIL, 'asso_mail': ASSO_EMAIL,
'site_name': SITE_NAME, 'site_name': SITE_NAME,