mirror of
https://github.com/ae-utbm/sith.git
synced 2026-11-20 16:09:54 +00:00
11 files changed
+185
-24
No files matched your search
+15
-2
@@ -302,12 +302,22 @@ class ClubRoleForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = ClubRole
|
||||
fields = ["name", "description", "is_presidency", "is_board", "is_active"]
|
||||
fields = [
|
||||
"name",
|
||||
"name_en",
|
||||
"description",
|
||||
"is_presidency",
|
||||
"is_board",
|
||||
"is_active",
|
||||
]
|
||||
widgets = {
|
||||
"is_presidency": forms.HiddenInput(),
|
||||
"is_board": forms.HiddenInput(),
|
||||
"is_active": forms.CheckboxInput(attrs={"class": "switch"}),
|
||||
}
|
||||
help_texts = {
|
||||
"name_en": _("Provide an english name for non-french speaking users.")
|
||||
}
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
@@ -354,7 +364,10 @@ class ClubRoleCreateForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = ClubRole
|
||||
fields = ["name", "description"]
|
||||
fields = ["name", "name_en", "description"]
|
||||
help_texts = {
|
||||
"name_en": _("Provide an english name for non-french speaking users.")
|
||||
}
|
||||
|
||||
def __init__(
|
||||
self, *args, club: Club, is_presidency: bool, is_board: bool, **kwargs
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# Generated by Django 5.2.18 on 2026-11-14 11:44
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.models import F
|
||||
from django.db.models.expressions import Case, Value, When
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
|
||||
def copy_name(apps: StateApps, schema_editor):
|
||||
"""Automatically populate French names and the most common English ones"""
|
||||
ClubRole = apps.get_model("club", "ClubRole")
|
||||
ClubRole.objects.update(
|
||||
name_fr=F("name"),
|
||||
name_en=Case(
|
||||
When(name="Président⸱e", then=Value("President")),
|
||||
When(name="Vice-Président⸱e", then=Value("Vice-president")),
|
||||
When(name="Trésorier⸱e", then=Value("Treasurer")),
|
||||
When(name="Responsable communication", then=Value("Communication manager")),
|
||||
When(name="Secrétaire", then=Value("Secretary")),
|
||||
When(name="Responsable info", then=Value("IT manager")),
|
||||
When(name="Membre du bureau", then=Value("Board member")),
|
||||
When(name="Membre actif⸱ve", then=Value("Active member")),
|
||||
When(name="Curieux⸱euse", then=Value("Curious")),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("club", "0019_remove_mailingsubscription_mailing_and_more")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="clubrole",
|
||||
name="name_en",
|
||||
field=models.CharField(max_length=50, null=True, verbose_name="name"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="clubrole",
|
||||
name="name_fr",
|
||||
field=models.CharField(max_length=50, null=True, verbose_name="name"),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="clubrole",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("club", "name"),
|
||||
name="clubrole_club_name_unique",
|
||||
violation_error_message="There is already a role with that name",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="clubrole",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("club", "name_fr"),
|
||||
name="clubrole_club_name_unique-fr",
|
||||
violation_error_message="There is already a role with that name",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="clubrole",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("club", "name_en"),
|
||||
name="clubrole_club_name_unique-en",
|
||||
violation_error_message="There is already a role with that name",
|
||||
),
|
||||
),
|
||||
migrations.RunPython(
|
||||
copy_name, reverse_code=migrations.RunPython.noop, elidable=True
|
||||
),
|
||||
]
|
||||
+6
-1
@@ -307,7 +307,12 @@ class ClubRole(OrderedModel):
|
||||
violation_error_message=_(
|
||||
"A role cannot be in the presidency while not being in the board"
|
||||
),
|
||||
)
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=("club", "name"),
|
||||
name="clubrole_club_name_unique",
|
||||
violation_error_message=_("There is already a role with that name"),
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
<div class="form-group">
|
||||
{{ subform.name.as_field_group() }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ subform.name_en.as_field_group() }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ subform.description.as_field_group() }}
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import translation
|
||||
from django.utils.timezone import now
|
||||
from model_bakery import baker, seq
|
||||
from model_bakery.recipe import Recipe
|
||||
@@ -281,3 +282,14 @@ class TestClubRoleUpdate(TestCase):
|
||||
# the second membership is finished, so its user shouldn't get the role
|
||||
assert members[0].user.groups.contains(self.club.board_group)
|
||||
assert not members[1].user.groups.contains(self.club.board_group)
|
||||
|
||||
def test_name_translation(self):
|
||||
"""Test that setting the english name works."""
|
||||
name_en = "something something"
|
||||
self.payload["roles-0-name_en"] = name_en
|
||||
formset = ClubRoleFormSet(data=self.payload, instance=self.club)
|
||||
assert formset.is_valid()
|
||||
formset.save()
|
||||
self.roles[0].refresh_from_db()
|
||||
with translation.override("en"):
|
||||
assert self.roles[0].name == name_en
|
||||
@@ -0,0 +1,8 @@
|
||||
from modeltranslation.translator import TranslationOptions, register
|
||||
|
||||
from club.models import ClubRole
|
||||
|
||||
|
||||
@register(ClubRole)
|
||||
class ClubRoleTranslationOptions(TranslationOptions):
|
||||
fields = ("name",)
|
||||
@@ -252,7 +252,6 @@ class Command(BaseCommand):
|
||||
date_of_birth="1942-06-12",
|
||||
password="plop",
|
||||
)
|
||||
User.objects.all().update(cgu_approved_at=now())
|
||||
User.groups.through.objects.bulk_create(
|
||||
[
|
||||
User.groups.through(group=groups.counter_admin, user=counter),
|
||||
@@ -277,6 +276,10 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
self._create_pages(groups)
|
||||
# the "approve cgu" button is shown if the cgu were approved
|
||||
# before the last version of the CGU page.
|
||||
# Hence, it's better for this update to be after page creation.
|
||||
User.objects.all().update(cgu_approved_at=now())
|
||||
|
||||
self._create_subscription(root)
|
||||
self._create_subscription(skia)
|
||||
@@ -779,28 +782,47 @@ class Command(BaseCommand):
|
||||
name="Carte AE", address="Jamais imprimée", parent=ae
|
||||
)
|
||||
roles = []
|
||||
presidency_roles = ["Président⸱e", "Vice-Président⸱e"]
|
||||
presidency_roles = [
|
||||
("Président⸱e", "President"),
|
||||
("Vice-Président⸱e", "Vice-president"),
|
||||
]
|
||||
board_roles = [
|
||||
"Trésorier⸱e",
|
||||
"Secrétaire",
|
||||
"Respo Info",
|
||||
"Respo Com",
|
||||
"Membre du bureau",
|
||||
("Trésorier⸱e", "Treasurer"),
|
||||
("Secrétaire", "Secretary"),
|
||||
("Respo Info", "IT manager"),
|
||||
("Respo Com", "Communication manager"),
|
||||
("Membre du bureau", "Board member"),
|
||||
]
|
||||
simple_roles = [
|
||||
("Membre actif⸱ve", "Active member"),
|
||||
("Curieux⸱euse", "Curious"),
|
||||
]
|
||||
simple_roles = ["Membre actif⸱ve", "Curieux⸱euse"]
|
||||
for club in ae, pdf, troll, refound:
|
||||
for i, role in enumerate(presidency_roles):
|
||||
for i, (role_fr, role_en) in enumerate(presidency_roles):
|
||||
roles.append(
|
||||
ClubRole(
|
||||
club=club, order=i, name=role, is_presidency=True, is_board=True
|
||||
club=club,
|
||||
order=i,
|
||||
name=role_fr,
|
||||
name_en=role_en,
|
||||
is_presidency=True,
|
||||
is_board=True,
|
||||
)
|
||||
)
|
||||
for i, role in enumerate(board_roles, start=len(presidency_roles)):
|
||||
roles.append(ClubRole(club=club, order=i, name=role, is_board=True))
|
||||
for i, role in enumerate(
|
||||
for i, (role_fr, role_en) in enumerate(
|
||||
board_roles, start=len(presidency_roles)
|
||||
):
|
||||
roles.append(
|
||||
ClubRole(
|
||||
club=club, order=i, name=role_fr, name_en=role_en, is_board=True
|
||||
)
|
||||
)
|
||||
for i, (role_fr, role_en) in enumerate(
|
||||
simple_roles, start=len(presidency_roles) + len(board_roles)
|
||||
):
|
||||
roles.append(ClubRole(club=club, order=i, name=role))
|
||||
roles.append(
|
||||
ClubRole(club=club, order=i, name=role_fr, name_en=role_en)
|
||||
)
|
||||
ClubRole.objects.bulk_create(roles)
|
||||
insta, fb, discord, _ = LinkType.objects.bulk_create(
|
||||
[
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-12 15:32+0100\n"
|
||||
"POT-Creation-Date: 2026-11-14 13:59+0100\n"
|
||||
"PO-Revision-Date: 2016-07-18\n"
|
||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@@ -251,6 +251,10 @@ msgstr "Inactif"
|
||||
msgid "All clubs"
|
||||
msgstr "Tous les clubs"
|
||||
|
||||
#: club/forms.py
|
||||
msgid "Provide an english name for non-french speaking users."
|
||||
msgstr "Fournissez un nom anglais pour les utilisateurs non-francophones."
|
||||
|
||||
#: club/models.py
|
||||
msgid "slug name"
|
||||
msgstr "nom slug"
|
||||
@@ -340,6 +344,10 @@ msgid "A role cannot be in the presidency while not being in the board"
|
||||
msgstr ""
|
||||
"Un rôle ne peut pas appartenir à la présidence sans être dans le bureau"
|
||||
|
||||
#: club/models.py
|
||||
msgid "There is already a role with that name"
|
||||
msgstr "Il existe déjà un rôle avec ce nom"
|
||||
|
||||
#: club/models.py
|
||||
#, python-format
|
||||
msgid "Role %(role)s cannot be placed below a member role"
|
||||
@@ -4344,7 +4352,8 @@ msgid ""
|
||||
"A minor is barman on this on this device, so you cannot currently sell "
|
||||
"alcohol."
|
||||
msgstr ""
|
||||
"Un mineur est barman sur cet appareil, vous ne pouvez donc pas vendre d'alcool actuellement."
|
||||
"Un mineur est barman sur cet appareil, vous ne pouvez donc pas vendre "
|
||||
"d'alcool actuellement."
|
||||
|
||||
#: counter/views/eticket.py
|
||||
msgid "people(s)"
|
||||
@@ -5499,14 +5508,14 @@ msgstr "Photos de %(user_name)s"
|
||||
msgid "Download all my pictures"
|
||||
msgstr "Télécharger toutes mes photos"
|
||||
|
||||
#: sith/settings.py
|
||||
msgid "English"
|
||||
msgstr "Anglais"
|
||||
|
||||
#: sith/settings.py
|
||||
msgid "French"
|
||||
msgstr "Français"
|
||||
|
||||
#: sith/settings.py
|
||||
msgid "English"
|
||||
msgstr "Anglais"
|
||||
|
||||
#: sith/settings.py
|
||||
msgid "TC"
|
||||
msgstr "TC"
|
||||
|
||||
@@ -52,6 +52,7 @@ dependencies = [
|
||||
"celery[redis]>=5.6.3,<7",
|
||||
"django-celery-results>=2.6.0,<3",
|
||||
"django-celery-beat>=2.9.0,<3",
|
||||
"django-modeltranslation>=0.20.6",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
||||
+2
-1
@@ -103,6 +103,7 @@ DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
SITE_ID = 4000
|
||||
|
||||
INSTALLED_APPS = (
|
||||
"modeltranslation",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
@@ -285,7 +286,7 @@ LOGGING = {
|
||||
|
||||
LANGUAGE_CODE = "fr-FR"
|
||||
|
||||
LANGUAGES = [("en", _("English")), ("fr", _("French"))]
|
||||
LANGUAGES = [("fr", _("French")), ("en", _("English"))]
|
||||
|
||||
TIME_ZONE = "Europe/Paris"
|
||||
|
||||
|
||||
@@ -703,6 +703,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/ae/63083bf0614a80857e264b9d3ae16af2e2eff7372da6e249abec7919cb0b/django_jinja-2.11.0-py3-none-any.whl", hash = "sha256:cc4c72246a6e346aa0574e0c56c3e534c1a20ef47b8476f05d7287781f69a0a9", size = 23748, upload-time = "2023-09-03T21:20:43.482Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "django-modeltranslation"
|
||||
version = "0.20.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "django" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a9/b7/049969e77ff4825836c78312b3b82bd58f94162ffe20bc46500f98391731/django_modeltranslation-0.20.6.tar.gz", hash = "sha256:29eb584f017206a0bea5e2a44ae5da514ad6ebf1e43536ff7fed7df67b795b0c", size = 82542, upload-time = "2026-09-07T12:03:24.651Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ab/55/dfd72b735f50bb633409326311598d9a5bc861ee81ae3d137844ab903add/django_modeltranslation-0.20.6-py3-none-any.whl", hash = "sha256:913658af75510a4f71573441f267b5831a6034c524f917f337adc666a60fe724", size = 99206, upload-time = "2026-09-07T12:03:23.238Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "django-ninja"
|
||||
version = "1.7.3"
|
||||
@@ -2061,6 +2074,7 @@ dependencies = [
|
||||
{ name = "django-haystack" },
|
||||
{ name = "django-honeypot" },
|
||||
{ name = "django-jinja" },
|
||||
{ name = "django-modeltranslation" },
|
||||
{ name = "django-ninja" },
|
||||
{ name = "django-ninja-extra" },
|
||||
{ name = "django-ordered-model" },
|
||||
@@ -2129,6 +2143,7 @@ requires-dist = [
|
||||
{ name = "django-haystack", specifier = ">=3.4.0,<4.0.0" },
|
||||
{ name = "django-honeypot", specifier = ">=1.3.0,<2" },
|
||||
{ name = "django-jinja", specifier = ">=2.11.0,<3.0.0" },
|
||||
{ name = "django-modeltranslation", specifier = ">=0.20.6" },
|
||||
{ name = "django-ninja", specifier = ">=1.7.1,<2.0.0" },
|
||||
{ name = "django-ninja-extra", specifier = ">=0.31.7" },
|
||||
{ name = "django-ordered-model", specifier = ">=3.7.4,<4.0.0" },
|
||||
|
||||
Reference in new issue
Block a user