Rename surname to last_name
This commit is contained in:
parent
e82053d16f
commit
3509491076
|
@ -41,20 +41,20 @@ def search_result(search, type, request):
|
|||
|
||||
if request.user.has_perms(('perm',)):
|
||||
query = Q(user__username__icontains=search) | Q(user__name__icontains=search) | Q(
|
||||
user__surname__icontains=search)
|
||||
user__last_name__icontains=search)
|
||||
else:
|
||||
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:
|
||||
if i == '0':
|
||||
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',)):
|
||||
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:
|
||||
recherche['users_list'] = User.objects.filter(query_user_list & Q(id=request.user.id)).order_by(
|
||||
'surname')
|
||||
'last_name')
|
||||
if i == '1':
|
||||
recherche['emprunts_list'] = Emprunt.objects.filter(query & date_query).order_by('date_emprunt').reverse()
|
||||
if i == '2':
|
||||
|
@ -63,7 +63,7 @@ def search_result(search, type, request):
|
|||
if i == '3':
|
||||
recherche['jeux_list'] = Jeu.objects.filter(
|
||||
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:
|
||||
if recherche[r] is not None:
|
||||
|
|
|
@ -111,7 +111,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<div class="panel panel-default">
|
||||
{% if request_user.is_authenticated %}
|
||||
<div class="panel-heading">
|
||||
<h4>{{ request_user.name }} {{ request_user.surname }}</h4>
|
||||
<h4>{{ request_user.name }} {{ request_user.last_name }}</h4>
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
|
@ -120,7 +120,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Nom</th>
|
||||
<td class="text-right">{{ request_user.surname }}</td>
|
||||
<td class="text-right">{{ request_user.last_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Prénom</th>
|
||||
|
|
|
@ -39,11 +39,11 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
# The fields to be used in displaying the User model.
|
||||
# These override the definitions on the base UserAdmin
|
||||
# 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 = ()
|
||||
fieldsets = (
|
||||
(None, {'fields': ('username', 'password')}),
|
||||
('Personal info', {'fields': ('name', 'surname', 'email')}),
|
||||
('Personal info', {'fields': ('name', 'last_name', 'email')}),
|
||||
('Permissions', {'fields': ('is_admin',)}),
|
||||
)
|
||||
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
|
||||
|
@ -51,7 +51,7 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
add_fieldsets = (
|
||||
(None, {
|
||||
'classes': ('wide',),
|
||||
'fields': ('username', 'name', 'surname', 'email', 'is_admin', 'password1', 'password2')}
|
||||
'fields': ('username', 'name', 'last_name', 'email', 'is_admin', 'password1', 'password2')}
|
||||
),
|
||||
)
|
||||
search_fields = ('username',)
|
||||
|
|
|
@ -28,7 +28,7 @@ class UserCreationForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'name', 'surname', 'email')
|
||||
fields = ('username', 'name', 'last_name', 'email')
|
||||
|
||||
def clean_password2(self):
|
||||
# Check that the two password entries match
|
||||
|
@ -57,7 +57,7 @@ class UserChangeForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'password', 'name', 'surname', 'email')
|
||||
fields = ('username', 'password', 'name', 'last_name', 'email')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(UserChangeForm, self).__init__(*args, **kwargs)
|
||||
|
@ -83,7 +83,7 @@ class BaseInfoForm(ModelForm):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(BaseInfoForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].label = 'Prénom'
|
||||
self.fields['surname'].label = 'Nom'
|
||||
self.fields['last_name'].label = 'Nom'
|
||||
# self.fields['comment'].label = 'Commentaire'
|
||||
|
||||
class Meta:
|
||||
|
@ -91,7 +91,7 @@ class BaseInfoForm(ModelForm):
|
|||
fields = [
|
||||
'name',
|
||||
'username',
|
||||
'surname',
|
||||
'last_name',
|
||||
'email',
|
||||
'telephone',
|
||||
'adresse',
|
||||
|
@ -103,7 +103,7 @@ class InfoForm(BaseInfoForm):
|
|||
fields = [
|
||||
'name',
|
||||
'username',
|
||||
'surname',
|
||||
'last_name',
|
||||
'email',
|
||||
'telephone',
|
||||
'adresse',
|
||||
|
|
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -17,7 +17,7 @@ from med.settings import MAX_EMPRUNT, REQ_EXPIRE_HRS
|
|||
class UserManager(BaseUserManager):
|
||||
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.
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@ class UserManager(BaseUserManager):
|
|||
user = self.model(
|
||||
username=username,
|
||||
name=name,
|
||||
surname=surname,
|
||||
last_name=last_name,
|
||||
email=email,
|
||||
)
|
||||
|
||||
|
@ -38,28 +38,27 @@ class UserManager(BaseUserManager):
|
|||
user.make_admin()
|
||||
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.
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
return self._create_user(username, name, surname, email, password, True)
|
||||
return self._create_user(username, name, last_name, email, password, True)
|
||||
|
||||
|
||||
class User(AbstractBaseUser):
|
||||
username_validator = UnicodeUsernameValidator() if six.PY3 else ASCIIUsernameValidator()
|
||||
PRETTY_NAME = "Utilisateurs"
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
surname = models.CharField(max_length=255)
|
||||
email = models.EmailField()
|
||||
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
||||
email = models.EmailField(_('email address'), blank=True)
|
||||
telephone = models.CharField(max_length=15, 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")
|
||||
|
@ -87,13 +86,14 @@ class User(AbstractBaseUser):
|
|||
'Unselect this instead of deleting accounts.'
|
||||
),
|
||||
)
|
||||
registered = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
USERNAME_FIELD = 'username'
|
||||
REQUIRED_FIELDS = ['name', 'surname', 'email']
|
||||
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
EMAIL_FIELD = 'email'
|
||||
USERNAME_FIELD = 'username'
|
||||
REQUIRED_FIELDS = ['name', 'last_name', 'email']
|
||||
|
||||
@property
|
||||
def is_admin(self):
|
||||
try:
|
||||
|
@ -118,7 +118,7 @@ class User(AbstractBaseUser):
|
|||
return False
|
||||
|
||||
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):
|
||||
return self.name
|
||||
|
|
|
@ -41,7 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% for user in users_list %}
|
||||
<tr>
|
||||
<td>{{ user.name }}</td>
|
||||
<td>{{ user.surname }}</td>
|
||||
<td>{{ user.last_name }}</td>
|
||||
<td>{{ user.username }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.maxemprunt }}</td>
|
||||
|
|
|
@ -61,7 +61,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<th>Prénom</th>
|
||||
<td>{{ user.name }}</td>
|
||||
<th>Nom</th>
|
||||
<td>{{ user.surname }}</td>
|
||||
<td>{{ user.last_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Pseudo</th>
|
||||
|
@ -73,7 +73,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<th>Commentaire</th>
|
||||
<td>{{ user.comment }}</td>
|
||||
<th>Date d'inscription</th>
|
||||
<td>{{ user.registered }}</td>
|
||||
<td>{{ user.date_joined }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Adresse</th>
|
||||
|
|
|
@ -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 """
|
||||
t = loader.get_template('users/email_passwd_request')
|
||||
c = {
|
||||
'name': str(req.user.name) + ' ' + str(req.user.surname),
|
||||
'name': str(req.user.name) + ' ' + str(req.user.last_name),
|
||||
'asso': ASSO_NAME,
|
||||
'asso_mail': ASSO_EMAIL,
|
||||
'site_name': SITE_NAME,
|
||||
|
|
Loading…
Reference in New Issue