Translate users models
This commit is contained in:
parent
f61d09b65e
commit
2ce5e122a4
|
@ -17,15 +17,15 @@ from .models import Adhesion, Clef, User
|
|||
|
||||
|
||||
class ClefAdmin(VersionAdmin):
|
||||
list_display = ('nom', 'proprio', 'commentaire')
|
||||
ordering = ('nom',)
|
||||
search_fields = ('nom', 'proprio__username', 'commentaire')
|
||||
autocomplete_fields = ('proprio',)
|
||||
list_display = ('name', 'owner', 'comment')
|
||||
ordering = ('name',)
|
||||
search_fields = ('name', 'owner__username', 'comment')
|
||||
autocomplete_fields = ('owner',)
|
||||
|
||||
|
||||
class AdhesionAdmin(VersionAdmin):
|
||||
list_display = ('annee_debut', 'annee_fin')
|
||||
autocomplete_fields = ('adherent',)
|
||||
list_display = ('starting_in', 'ending_in')
|
||||
autocomplete_fields = ('members',)
|
||||
|
||||
|
||||
class IsAdherentFilter(admin.SimpleListFilter):
|
||||
|
@ -41,7 +41,7 @@ class IsAdherentFilter(admin.SimpleListFilter):
|
|||
value = self.value()
|
||||
if value == 'Yes':
|
||||
# Get current membership year and list all members
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
|
||||
last_adh_year = Adhesion.objects.all().order_by('starting_in') \
|
||||
.reverse().first()
|
||||
return last_adh_year.adherent
|
||||
return queryset
|
||||
|
@ -95,7 +95,7 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
"""
|
||||
Get current membership year and check if user is there
|
||||
"""
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
|
||||
last_adh_year = Adhesion.objects.all().order_by('starting_in') \
|
||||
.reverse().first()
|
||||
is_member = last_adh_year and obj in last_adh_year.adherent.all()
|
||||
if is_member:
|
||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-08-10 15:56+0200\n"
|
||||
"POT-Creation-Date: 2019-08-10 16:12+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -19,7 +19,7 @@ msgstr "statut adhérent"
|
|||
|
||||
#: admin.py:37
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
msgstr "Oui"
|
||||
|
||||
#: admin.py:54
|
||||
msgid "Personal info"
|
||||
|
@ -69,7 +69,7 @@ msgstr "emprunts maximal"
|
|||
msgid "Maximal amount of simultaneous borrowed item authorized."
|
||||
msgstr "Nombre maximal d'objets empruntés en même temps."
|
||||
|
||||
#: models.py:33
|
||||
#: models.py:33 models.py:67
|
||||
msgid "comment"
|
||||
msgstr "commentaire"
|
||||
|
||||
|
@ -81,6 +81,50 @@ msgstr ""
|
|||
msgid "date joined"
|
||||
msgstr ""
|
||||
|
||||
#: models.py:55
|
||||
msgid "name"
|
||||
msgstr "nom"
|
||||
|
||||
#: models.py:62
|
||||
msgid "owner"
|
||||
msgstr "propriétaire"
|
||||
|
||||
#: models.py:74
|
||||
msgid "key"
|
||||
msgstr "clé"
|
||||
|
||||
#: models.py:75
|
||||
msgid "keys"
|
||||
msgstr "clés"
|
||||
|
||||
#: models.py:80
|
||||
msgid "starting in"
|
||||
msgstr "commence en"
|
||||
|
||||
#: models.py:81
|
||||
msgid "Year in which the membership year starts."
|
||||
msgstr "Année dans laquelle la plage d'adhésion commence."
|
||||
|
||||
#: models.py:85
|
||||
msgid "ending in"
|
||||
msgstr "finie en"
|
||||
|
||||
#: models.py:86
|
||||
msgid "Year in which the membership year ends."
|
||||
msgstr "Année dans laquelle la plage d'adhésion finie."
|
||||
|
||||
#: models.py:91
|
||||
msgid "members"
|
||||
msgstr "adhérents"
|
||||
|
||||
#: models.py:96
|
||||
msgid "membership year"
|
||||
msgstr "année d'adhésion"
|
||||
|
||||
#: models.py:97
|
||||
msgid "membership years"
|
||||
msgstr "années d'adhésion"
|
||||
|
||||
#: templates/users/user.html:40
|
||||
msgid "Change password"
|
||||
msgstr ""
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:00
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0029_auto_20190810_1121'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='clef',
|
||||
old_name='nom',
|
||||
new_name='name',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0030_auto_20190810_1600'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='clef',
|
||||
old_name='proprio',
|
||||
new_name='owner',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0031_auto_20190810_1601'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='clef',
|
||||
old_name='commentaire',
|
||||
new_name='comment',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:02
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0032_auto_20190810_1601'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='clef',
|
||||
name='comment',
|
||||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='comment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clef',
|
||||
name='name',
|
||||
field=models.CharField(max_length=255, unique=True, verbose_name='name'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clef',
|
||||
name='owner',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='owner'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:04
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0033_auto_20190810_1602'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='adhesion',
|
||||
name='adherent',
|
||||
field=models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL, verbose_name='members'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='adhesion',
|
||||
name='annee_debut',
|
||||
field=models.IntegerField(unique=True, verbose_name='starting in'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='adhesion',
|
||||
name='annee_fin',
|
||||
field=models.IntegerField(unique=True, verbose_name='ending in'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0034_auto_20190810_1604'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='adhesion',
|
||||
old_name='adherent',
|
||||
new_name='members',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0035_auto_20190810_1604'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='adhesion',
|
||||
old_name='annee_fin',
|
||||
new_name='ending_in',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='adhesion',
|
||||
old_name='annee_debut',
|
||||
new_name='starting_in',
|
||||
),
|
||||
]
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0036_auto_20190810_1604'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='adhesion',
|
||||
name='ending_in',
|
||||
field=models.IntegerField(help_text='Year in which the membership year ends.', unique=True, verbose_name='ending in'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='adhesion',
|
||||
name='starting_in',
|
||||
field=models.IntegerField(help_text='Year in which the membership year starts.', unique=True, verbose_name='starting in'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:10
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0037_auto_20190810_1608'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='adhesion',
|
||||
options={'verbose_name': 'membership year', 'verbose_name_plural': 'membership years'},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.2.4 on 2019-08-10 14:10
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0038_auto_20190810_1610'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='clef',
|
||||
options={'verbose_name': 'key', 'verbose_name_plural': 'keys'},
|
||||
),
|
||||
]
|
|
@ -46,18 +46,52 @@ class User(AbstractUser):
|
|||
@property
|
||||
def is_adherent(self):
|
||||
last_adh_year = Adhesion.objects.all().order_by(
|
||||
'annee_debut').reverse().first()
|
||||
'starting_in').reverse().first()
|
||||
return last_adh_year and self in last_adh_year.adherent.all()
|
||||
|
||||
|
||||
class Clef(models.Model):
|
||||
nom = models.CharField(max_length=255, unique=True)
|
||||
proprio = models.ForeignKey('User', on_delete=models.PROTECT, blank=True,
|
||||
null=True)
|
||||
commentaire = models.CharField(max_length=255, null=True, blank=True)
|
||||
name = models.CharField(
|
||||
verbose_name=_('name'),
|
||||
max_length=255,
|
||||
unique=True,
|
||||
)
|
||||
owner = models.ForeignKey(
|
||||
'User',
|
||||
on_delete=models.PROTECT,
|
||||
verbose_name=_('owner'),
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
comment = models.CharField(
|
||||
verbose_name=_('comment'),
|
||||
max_length=255,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('key')
|
||||
verbose_name_plural = _('keys')
|
||||
|
||||
|
||||
class Adhesion(models.Model):
|
||||
annee_debut = models.IntegerField(unique=True)
|
||||
annee_fin = models.IntegerField(unique=True)
|
||||
adherent = models.ManyToManyField('User', blank=True)
|
||||
starting_in = models.IntegerField(
|
||||
verbose_name=_('starting in'),
|
||||
help_text=_('Year in which the membership year starts.'),
|
||||
unique=True,
|
||||
)
|
||||
ending_in = models.IntegerField(
|
||||
verbose_name=_('ending in'),
|
||||
help_text=_('Year in which the membership year ends.'),
|
||||
unique=True,
|
||||
)
|
||||
members = models.ManyToManyField(
|
||||
'User',
|
||||
verbose_name=_('members'),
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('membership year')
|
||||
verbose_name_plural = _('membership years')
|
||||
|
|
|
@ -49,7 +49,7 @@ def adherer(request, userid):
|
|||
except User.DoesNotExist:
|
||||
messages.error(request, "Utilisateur inexistant")
|
||||
return redirect("admin:users_user_changelist")
|
||||
adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
|
||||
adh_year = Adhesion.objects.all().order_by('starting_in').reverse().first()
|
||||
if not adh_year:
|
||||
messages.error(request, "Année d'adhésion non définie")
|
||||
return redirect("admin:users_user_changelist")
|
||||
|
|
Loading…
Reference in New Issue