mirror of
https://github.com/ae-utbm/sith.git
synced 2026-12-04 06:42:47 +00:00
also forbid subscribers, old subscribers and public
This commit is contained in:
1 parent
c219958e48
commit
2c19e7b3fe
3 files changed
+34
-7
No files matched your search
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-30 13:53+0100\n"
|
||||
"POT-Creation-Date: 2026-12-02 13:40+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"
|
||||
@@ -5412,6 +5412,11 @@ msgstr[1] ""
|
||||
"que n'importe qui pourrait devenir éditeur simplement en rejoignant un des "
|
||||
"club."
|
||||
|
||||
#: sas/forms.py
|
||||
#, python-format
|
||||
msgid "%(group)s : this group cannot get album edition rights."
|
||||
msgstr "%(group)s : ce groupe ne peut pas recevoir le droit d'éditer un album."
|
||||
|
||||
#: sas/forms.py
|
||||
msgid "You already requested moderation for this picture."
|
||||
msgstr "Vous avez déjà déposé une demande de retrait pour cette photo."
|
||||
|
||||
+25
-4
@@ -4,7 +4,9 @@ from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models import Q
|
||||
from django.utils.timezone import get_current_timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext_lazy
|
||||
@@ -18,7 +20,6 @@ from sas.models import Album, Picture, PictureModerationRequest
|
||||
from sas.widgets.ajax_select import AutoCompleteSelectAlbum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.models import QuerySet
|
||||
from django.db.models.fields.files import FieldFile
|
||||
|
||||
from core.models import Group, User
|
||||
@@ -87,10 +88,16 @@ class AlbumEditForm(forms.ModelForm):
|
||||
return f
|
||||
|
||||
def clean_edit_groups(self):
|
||||
groups: QuerySet[Group] = self.cleaned_data["edit_groups"]
|
||||
member_groups = list(groups.exclude(club=None).values_list("name", flat=True))
|
||||
groups: list[Group] = list(
|
||||
self.cleaned_data["edit_groups"].annotate(
|
||||
is_club_group=Q(club__isnull=False)
|
||||
)
|
||||
)
|
||||
member_groups = [g.name for g in groups if g.is_club_group]
|
||||
if member_groups:
|
||||
raise ValidationError(
|
||||
self.add_error(
|
||||
"edit_groups",
|
||||
ValidationError(
|
||||
ngettext_lazy(
|
||||
"You cannot grant the edit rights "
|
||||
"to the %(groups)s group. "
|
||||
@@ -103,6 +110,20 @@ class AlbumEditForm(forms.ModelForm):
|
||||
number=len(member_groups),
|
||||
)
|
||||
% {"groups": ", ".join(member_groups)}
|
||||
),
|
||||
)
|
||||
for group in groups:
|
||||
if group.id in [
|
||||
settings.SITH_GROUP_SUBSCRIBERS_ID,
|
||||
settings.SITH_GROUP_OLD_SUBSCRIBERS_ID,
|
||||
settings.SITH_GROUP_PUBLIC_ID,
|
||||
]:
|
||||
self.add_error(
|
||||
"edit_groups",
|
||||
ValidationError(
|
||||
_("%(group)s : this group cannot get album edition rights.")
|
||||
% {"group": group.name}
|
||||
),
|
||||
)
|
||||
return groups
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ def test_club_member_groups_cannot_be_edit_groups(album: Album):
|
||||
"name": album.name,
|
||||
"parent": album.pk,
|
||||
"date": localdate(),
|
||||
"edit_groups": [club.members_group_id],
|
||||
"edit_groups": [club.members_group_id, settings.SITH_GROUP_SUBSCRIBERS_ID],
|
||||
}
|
||||
form = AlbumEditForm(data=data)
|
||||
assert not form.is_valid()
|
||||
@@ -121,7 +121,8 @@ def test_club_member_groups_cannot_be_edit_groups(album: Album):
|
||||
f"d'édition au groupe {club.members_group.name}. "
|
||||
"C'est un groupe de simples membres de club, "
|
||||
"ce qui signifie que n'importe qui pourrait devenir éditeur "
|
||||
"simplement en rejoignant le club."
|
||||
"simplement en rejoignant le club.",
|
||||
"Cotisants : ce groupe ne peut pas recevoir le droit d'éditer un album.",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user