mirror of
https://github.com/ae-utbm/sith.git
synced 2026-12-04 06:42:47 +00:00
forbid club simple member groups in album edit groups.
This commit is contained in:
1 parent
ebb43658e1
commit
c219958e48
3 files changed
+69
-3
No files matched your search
@@ -15,6 +15,7 @@ from model_bakery import baker
|
||||
from PIL import Image
|
||||
from pytest_django.asserts import assertInHTML, assertRedirects
|
||||
|
||||
from club.models import Club
|
||||
from core.baker_recipes import subscriber_user
|
||||
from core.models import Group, User
|
||||
from core.utils import RED_PIXEL_PNG
|
||||
@@ -90,7 +91,8 @@ def test_form_required(album: Album, excluded: str, is_valid: bool): # noqa: FB
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_form_album_name(album: Album):
|
||||
def test_form_album_name_length(album: Album):
|
||||
"""Test that the album name length constraint is enforced"""
|
||||
data = {
|
||||
"name": "a" * Album.NAME_MAX_LENGTH,
|
||||
"parent": album.pk,
|
||||
@@ -102,6 +104,28 @@ def test_form_album_name(album: Album):
|
||||
assert not AlbumEditForm(data=data).is_valid()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_club_member_groups_cannot_be_edit_groups(album: Album):
|
||||
club = baker.make(Club)
|
||||
data = {
|
||||
"name": album.name,
|
||||
"parent": album.pk,
|
||||
"date": localdate(),
|
||||
"edit_groups": [club.members_group_id],
|
||||
}
|
||||
form = AlbumEditForm(data=data)
|
||||
assert not form.is_valid()
|
||||
assert form.errors == {
|
||||
"edit_groups": [
|
||||
f"Vous ne pouvez pas accorder les droits "
|
||||
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."
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_update_recursive_parent(client: Client, album: Album):
|
||||
client.force_login(baker.make(User, is_superuser=True))
|
||||
|
||||
Reference in new issue
Block a user