From 2ce5e122a44e00265425e96c740f6fc4671bdbc7 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 10 Aug 2019 16:13:32 +0200 Subject: [PATCH] Translate users models --- users/admin.py | 16 +++---- users/locale/fr/LC_MESSAGES/django.po | 50 +++++++++++++++++++-- users/migrations/0030_auto_20190810_1600.py | 18 ++++++++ users/migrations/0031_auto_20190810_1601.py | 18 ++++++++ users/migrations/0032_auto_20190810_1601.py | 18 ++++++++ users/migrations/0033_auto_20190810_1602.py | 30 +++++++++++++ users/migrations/0034_auto_20190810_1604.py | 29 ++++++++++++ users/migrations/0035_auto_20190810_1604.py | 18 ++++++++ users/migrations/0036_auto_20190810_1604.py | 23 ++++++++++ users/migrations/0037_auto_20190810_1608.py | 23 ++++++++++ users/migrations/0038_auto_20190810_1610.py | 17 +++++++ users/migrations/0039_auto_20190810_1610.py | 17 +++++++ users/models.py | 50 +++++++++++++++++---- users/views.py | 2 +- 14 files changed, 309 insertions(+), 20 deletions(-) create mode 100644 users/migrations/0030_auto_20190810_1600.py create mode 100644 users/migrations/0031_auto_20190810_1601.py create mode 100644 users/migrations/0032_auto_20190810_1601.py create mode 100644 users/migrations/0033_auto_20190810_1602.py create mode 100644 users/migrations/0034_auto_20190810_1604.py create mode 100644 users/migrations/0035_auto_20190810_1604.py create mode 100644 users/migrations/0036_auto_20190810_1604.py create mode 100644 users/migrations/0037_auto_20190810_1608.py create mode 100644 users/migrations/0038_auto_20190810_1610.py create mode 100644 users/migrations/0039_auto_20190810_1610.py diff --git a/users/admin.py b/users/admin.py index f4adab3..50caf22 100644 --- a/users/admin.py +++ b/users/admin.py @@ -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: diff --git a/users/locale/fr/LC_MESSAGES/django.po b/users/locale/fr/LC_MESSAGES/django.po index d5a390f..7d21508 100644 --- a/users/locale/fr/LC_MESSAGES/django.po +++ b/users/locale/fr/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/users/migrations/0030_auto_20190810_1600.py b/users/migrations/0030_auto_20190810_1600.py new file mode 100644 index 0000000..cfccf38 --- /dev/null +++ b/users/migrations/0030_auto_20190810_1600.py @@ -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', + ), + ] diff --git a/users/migrations/0031_auto_20190810_1601.py b/users/migrations/0031_auto_20190810_1601.py new file mode 100644 index 0000000..e41a7c3 --- /dev/null +++ b/users/migrations/0031_auto_20190810_1601.py @@ -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', + ), + ] diff --git a/users/migrations/0032_auto_20190810_1601.py b/users/migrations/0032_auto_20190810_1601.py new file mode 100644 index 0000000..b5ead7b --- /dev/null +++ b/users/migrations/0032_auto_20190810_1601.py @@ -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', + ), + ] diff --git a/users/migrations/0033_auto_20190810_1602.py b/users/migrations/0033_auto_20190810_1602.py new file mode 100644 index 0000000..aadfc02 --- /dev/null +++ b/users/migrations/0033_auto_20190810_1602.py @@ -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'), + ), + ] diff --git a/users/migrations/0034_auto_20190810_1604.py b/users/migrations/0034_auto_20190810_1604.py new file mode 100644 index 0000000..4d817b7 --- /dev/null +++ b/users/migrations/0034_auto_20190810_1604.py @@ -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'), + ), + ] diff --git a/users/migrations/0035_auto_20190810_1604.py b/users/migrations/0035_auto_20190810_1604.py new file mode 100644 index 0000000..bf4a4b9 --- /dev/null +++ b/users/migrations/0035_auto_20190810_1604.py @@ -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', + ), + ] diff --git a/users/migrations/0036_auto_20190810_1604.py b/users/migrations/0036_auto_20190810_1604.py new file mode 100644 index 0000000..7b351ce --- /dev/null +++ b/users/migrations/0036_auto_20190810_1604.py @@ -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', + ), + ] diff --git a/users/migrations/0037_auto_20190810_1608.py b/users/migrations/0037_auto_20190810_1608.py new file mode 100644 index 0000000..68bb18e --- /dev/null +++ b/users/migrations/0037_auto_20190810_1608.py @@ -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'), + ), + ] diff --git a/users/migrations/0038_auto_20190810_1610.py b/users/migrations/0038_auto_20190810_1610.py new file mode 100644 index 0000000..29c6cb9 --- /dev/null +++ b/users/migrations/0038_auto_20190810_1610.py @@ -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'}, + ), + ] diff --git a/users/migrations/0039_auto_20190810_1610.py b/users/migrations/0039_auto_20190810_1610.py new file mode 100644 index 0000000..8f45d93 --- /dev/null +++ b/users/migrations/0039_auto_20190810_1610.py @@ -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'}, + ), + ] diff --git a/users/models.py b/users/models.py index aa61122..a6cb6e4 100644 --- a/users/models.py +++ b/users/models.py @@ -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') diff --git a/users/views.py b/users/views.py index c5152da..f1e0aab 100644 --- a/users/views.py +++ b/users/views.py @@ -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")