Compare commits

..
Author SHA1 Message Date
thomas girod b5b14322b2 Merge pull request #1556 from ae-utbm/taiste
uv-managed uwsgi, model translation, some user tools and bugfixes
2026-11-20 16:55:11 +01:00
thomas girod 828cc2f7bf Merge pull request #1531 from ae-utbm/taiste
Timetable saving, club news page, bugfixes and other
2026-10-26 23:21:01 +01:00
thomas girod 86730d4f7a Merge pull request #1509 from ae-utbm/taiste
Third-party auth, UE guide style, CGU, and bugfixes
2026-10-02 18:51:20 +02:00
thomas girod 6a6ed5462f Merge pull request #1491 from ae-utbm/taiste
Python 3.14, HTMX4, client-side markdown, pedagogy rework and others
2026-09-18 19:19:48 +02:00
thomas girod d914fa0658 Merge pull request #1463 from ae-utbm/taiste
Pre school year release
2026-08-25 22:37:49 +02:00
19 changed files with 32 additions and 333 deletions

No files matched your search

+2 -30
View File
@@ -25,7 +25,6 @@ import itertools
from operator import attrgetter
from django import forms
from django.conf import settings
from django.db.models import Exists, OuterRef, Q, QuerySet
from django.db.models.functions import Lower
from django.forms.models import ModelChoiceField, ModelChoiceIterator
@@ -183,12 +182,7 @@ class ClubOldMemberForm(forms.Form):
class ClubMemberForm(forms.ModelForm):
"""Base form to create a Membership.
Two subclasses exist :
- one for adding any user to a club, that is shown to board members
- the other for users without privileges to join the club as simple members.
"""
"""Form to add a member to the club, as a board member."""
error_css_class = "error"
required_css_class = "required"
@@ -253,29 +247,9 @@ class ClubAddMemberForm(ClubMemberForm):
)
return user
def clean(self):
res = super().clean()
if self.errors:
return res
user, role = self.cleaned_data["user"], self.cleaned_data["role"]
if (
role.is_board
and user.ban_groups.filter(
id=settings.SITH_GROUP_BANNED_RESPONSIBILITY_ID
).exists()
):
raise forms.ValidationError(
_("This user is banned from being in the board of a club"),
code="banned",
)
return res
class JoinClubForm(ClubMemberForm):
"""Form to join a club.
Only member roles can be obtained through this form.
"""
"""Form to join a club."""
def __init__(self, *args, club: Club, request_user: User, **kwargs):
super().__init__(*args, club=club, request_user=request_user, **kwargs)
@@ -287,8 +261,6 @@ class JoinClubForm(ClubMemberForm):
def clean(self):
"""Check that the user is subscribed and isn't already in the club."""
# note: we don't check here if users are ban from joining a club board,
# because this form manages only member roles.
if not self.request_user.is_subscribed:
raise forms.ValidationError(
_("You must be subscribed to join a club"), code="invalid"
+6 -12
View File
@@ -421,24 +421,18 @@ class MembershipQuerySet(models.QuerySet):
"""Remove users from club groups they are no more in
and add them in the club groups they should be in.
Be aware that this adds four db queries (on top of the UPDATE query) :
Be aware that this adds three db queries :
- two to retrieve the updated memberships
- one to retrieve the updated memberships
- one to perform group removal
- and one to perform group attribution.
"""
memberships = set(self.values_list("id", flat=True))
if not memberships:
# if there is no selected membership,there is nothing to do
return 0
nb_rows = super().update(**kwargs)
if nb_rows == 0:
# if no row was affected, no need to edit club groups
return 0
# re-fetch the updated objects, with their new state.
memberships = set(
Membership.objects.filter(id__in=memberships)
.select_related("club", "role")
.prefetch_related("role__linked_groups")
)
memberships = set(self.select_related("club"))
# delete all User-Group relations and recreate the necessary ones
Membership._remove_club_groups(memberships)
Membership._add_club_groups(memberships)
+1 -21
View File
@@ -4,7 +4,6 @@ from typing import TYPE_CHECKING
import pytest
from bs4 import BeautifulSoup
from django.conf import settings
from django.contrib.auth.models import Permission
from django.core.cache import cache
from django.db.models import Max
@@ -18,7 +17,7 @@ from club.forms import ClubAddMemberForm, JoinClubForm
from club.models import Club, ClubRole, Membership
from club.tests.base import TestClub
from core.baker_recipes import subscriber_user
from core.models import AnonymousUser, Group, User, UserBan
from core.models import AnonymousUser, Group, User
if TYPE_CHECKING:
from collections.abc import Callable
@@ -387,25 +386,6 @@ class TestMembership(TestClub):
"user": ["Vous ne pouvez pas ajouter deux fois le même utilisateur"]
}
def test_add_banned_user(self):
user = subscriber_user.make()
baker.make(
UserBan,
ban_group_id=settings.SITH_GROUP_BANNED_RESPONSIBILITY_ID,
user=user,
)
form = ClubAddMemberForm(
data={"user": user, "role": self.board_role},
request_user=self.root,
club=self.club,
)
assert not form.is_valid()
assert form.errors == {
"__all__": [
"Cette personne a l'interdiction de rejoindre le bureau d'un club."
]
}
def test_add_other_member_forbidden(self):
non_member = subscriber_user.make()
simple_member = baker.make(
+1 -1
View File
@@ -36,7 +36,7 @@ class GroupAdmin(admin.ModelAdmin):
list_display = ("name", "description", "is_manually_manageable")
list_filter = ("is_manually_manageable",)
search_fields = ("name",)
autocomplete_fields = ("permissions", "manageable_by")
autocomplete_fields = ("permissions",)
@admin.register(BanGroup)
-1
View File
@@ -1006,7 +1006,6 @@ class Command(BaseCommand):
BanGroup.objects.create(name="Banned from buying alcohol", description="")
BanGroup.objects.create(name="Banned from counters", description="")
BanGroup.objects.create(name="Banned to subscribe", description="")
BanGroup.objects.create(name="Responsibility ban", description="")
def _create_elections(
self,
@@ -1,26 +0,0 @@
# Generated by Django 5.2.19 on 2026-12-04 13:24
from django.db import migrations, models
import core.models
class Migration(migrations.Migration):
dependencies = [("core", "0053_alter_user_email_alter_user_second_email")]
operations = [
migrations.AlterModelManagers(
name="group", managers=[("objects", core.models.CustomGroupManager())]
),
migrations.AddField(
model_name="group",
name="manageable_by",
field=models.ManyToManyField(
blank=True,
help_text="Groups that are able to grant and remove this group.",
related_name="managed_groups",
to="core.group",
verbose_name="manageable by",
),
),
]
+1 -25
View File
@@ -33,7 +33,7 @@ from typing import TYPE_CHECKING, Final, Self
from uuid import uuid4
from django.conf import settings
from django.contrib.auth.models import AbstractUser, GroupManager, UserManager
from django.contrib.auth.models import AbstractUser, UserManager
from django.contrib.auth.models import AnonymousUser as AuthAnonymousUser
from django.contrib.auth.models import Group as AuthGroup
from django.contrib.staticfiles.storage import staticfiles_storage
@@ -65,19 +65,6 @@ if TYPE_CHECKING:
from club.models import Club
class GroupQuerySet(models.QuerySet):
def manageable_by(self, user: User):
"""Filter groups that are editable by this user in the sith UI."""
if user.has_perm("core.change_group"):
return self.filter(is_manually_manageable=True)
return self.filter(
is_manually_manageable=True, manageable_by__in=user.groups.all()
)
class CustomGroupManager(GroupManager.from_queryset(GroupQuerySet)): ...
class Group(AuthGroup):
"""Wrapper around django.auth.Group"""
@@ -87,15 +74,6 @@ class Group(AuthGroup):
help_text=_("If False, this shouldn't be shown on group management pages"),
)
description = models.TextField(_("description"))
manageable_by = models.ManyToManyField(
"Group",
verbose_name=_("manageable by"),
help_text=_("Groups that are able to grant and remove this group."),
related_name="managed_groups",
blank=True,
)
objects = CustomGroupManager()
def get_absolute_url(self) -> str:
return reverse("core:group_list")
@@ -797,8 +775,6 @@ class UserBan(models.Model):
settings.SITH_GROUP_BANNED_SUBSCRIPTION_ID,
]:
self.user.counters.clear()
if self.ban_group_id == settings.SITH_GROUP_BANNED_RESPONSIBILITY_ID:
self.user.memberships.ongoing().board().update(end_date=localdate())
return super().save(*args, **kwargs)
-56
View File
@@ -295,49 +295,6 @@ def test_user_update_groups(client: Client):
}
@pytest.mark.django_db
def test_user_update_groups_non_admin(client: Client):
"""Test that a non-admin user can update the groups it is allowed to."""
managed_group = baker.make(Group, is_manually_manageable=True)
other_group = baker.make(Group, is_manually_manageable=True)
operator = subscriber_user.make(
groups=[baker.make(Group, managed_groups=[managed_group])]
)
user = baker.make(User, groups=[other_group])
client.force_login(operator)
response = client.post(
reverse("core:user_groups", kwargs={"user_id": user.id}),
data={"groups": [managed_group.id]},
)
assertRedirects(response, user.get_absolute_url())
# the manageable group should have been attributed
# and the non-manageable groups should be kept
assert set(user.groups.all()) == {
Group.objects.get(pk=settings.SITH_GROUP_PUBLIC_ID),
managed_group,
other_group,
}
@pytest.mark.django_db
def test_user_update_groups_denied(client: Client):
"""Test that a user that can manage no group cannot access the page at all."""
operator = subscriber_user.make(groups=[baker.make(Group)])
user = baker.make(User)
client.force_login(operator)
response = client.get(reverse("core:user_groups", kwargs={"user_id": user.id}))
assert response.status_code == 403
response = client.post(
reverse("core:user_groups", kwargs={"user_id": user.id}),
data={"groups": [baker.make(Group).id]},
)
assert response.status_code == 403
# no group should have been attributed at all
assert set(user.groups.all()) == {
Group.objects.get(pk=settings.SITH_GROUP_PUBLIC_ID)
}
@pytest.mark.django_db
def test_logout(client: Client):
user = baker.make(User)
@@ -421,19 +378,6 @@ def test_displayed_user_self_tabs(user_factory, expected_tabs: list[str]):
"account",
],
),
(
# this user is in a group that is allowed to manage another group
# so the groups tab should be displayed
lambda: subscriber_user.make(
groups=[
baker.make(
Group,
managed_groups=[baker.make(Group, is_manually_manageable=True)],
)
]
),
["infos", "godfathers", "pictures", "clubs", "groups"],
),
],
)
def test_displayed_other_user_tabs(user_factory, expected_tabs: list[str]):
+2 -6
View File
@@ -366,7 +366,7 @@ class UserGroupsForm(forms.ModelForm):
required_css_class = "required"
groups = forms.ModelMultipleChoiceField(
queryset=Group.objects.none(),
queryset=Group.objects.filter(is_manually_manageable=True),
widget=CheckboxSelectMultiple,
label=_("Groups"),
required=False,
@@ -376,10 +376,6 @@ class UserGroupsForm(forms.ModelForm):
model = User
fields = ["groups"]
def __init__(self, *args, request_user: User, **kwargs):
super().__init__(*args, **kwargs)
self.fields["groups"].queryset = Group.objects.manageable_by(request_user).all()
def save(self, *args, **kwargs) -> User:
# make the super method manage error without persisting in db
super().save(commit=False)
@@ -388,7 +384,7 @@ class UserGroupsForm(forms.ModelForm):
self.instance.groups.set(
[
*self.cleaned_data["groups"],
*self.instance.groups.difference(self.fields["groups"].queryset),
*self.instance.groups.filter(is_manually_manageable=False),
]
)
return self.instance
+5 -10
View File
@@ -26,6 +26,7 @@ from django.utils.translation import gettext_lazy as _
from django.views.generic import ListView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from core.auth.mixins import CanEditMixin
from core.models import Group, User
from core.views import DetailFormView
from core.views.forms import PermissionGroupsForm
@@ -60,19 +61,16 @@ class EditMembersForm(forms.Form):
# Views
class GroupListView(PermissionRequiredMixin, ListView):
class GroupListView(CanEditMixin, ListView):
"""Displays the Group list."""
model = Group
queryset = Group.objects.filter(is_manually_manageable=True)
ordering = ["name"]
template_name = "core/group_list.jinja"
# This page is basically a list of links towards group edit pages,
# so give access only to users who can edit groups
permission_required = "core.change_group"
class GroupEditView(PermissionRequiredMixin, UpdateView):
class GroupEditView(CanEditMixin, UpdateView):
"""Edit infos of a Group."""
model = Group
@@ -80,7 +78,6 @@ class GroupEditView(PermissionRequiredMixin, UpdateView):
pk_url_kwarg = "group_id"
template_name = "core/group_edit.jinja"
fields = ["name", "description"]
permission_required = "core.change_group"
class GroupCreateView(PermissionRequiredMixin, CreateView):
@@ -93,7 +90,7 @@ class GroupCreateView(PermissionRequiredMixin, CreateView):
permission_required = "core.add_group"
class GroupTemplateView(PermissionRequiredMixin, DetailFormView):
class GroupTemplateView(CanEditMixin, DetailFormView):
"""Display all users in a given Group
Allow adding and removing users from it.
"""
@@ -103,7 +100,6 @@ class GroupTemplateView(PermissionRequiredMixin, DetailFormView):
form_class = EditMembersForm
pk_url_kwarg = "group_id"
template_name = "core/group_detail.jinja"
permission_required = "core.change_group"
def form_valid(self, form):
resp = super().form_valid(form)
@@ -131,7 +127,7 @@ class GroupTemplateView(PermissionRequiredMixin, DetailFormView):
return kwargs
class GroupDeleteView(PermissionRequiredMixin, DeleteView):
class GroupDeleteView(CanEditMixin, DeleteView):
"""Delete a Group."""
model = Group
@@ -139,7 +135,6 @@ class GroupDeleteView(PermissionRequiredMixin, DeleteView):
pk_url_kwarg = "group_id"
template_name = "core/delete_confirm.jinja"
success_url = reverse_lazy("core:group_list")
permission_required = "core.delete_group"
class PermissionGroupsUpdateView(
+4 -19
View File
@@ -33,10 +33,7 @@ from django.contrib import messages
from django.contrib.auth import login, views
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import SetPasswordForm
from django.contrib.auth.mixins import (
LoginRequiredMixin,
UserPassesTestMixin,
)
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.core.exceptions import PermissionDenied
from django.db.models import DateField, F, QuerySet, Sum
@@ -61,7 +58,7 @@ from django.views.generic.edit import FormView, UpdateView
from honeypot.decorators import check_honeypot
from core.auth.mixins import CanEditMixin, CanEditPropMixin, CanViewMixin
from core.models import Gift, Group, Preferences, User
from core.models import Gift, Preferences, User
from core.views.forms import (
CGUApprovalForm,
GiftForm,
@@ -299,10 +296,7 @@ class UserTabsMixin(TabedViewMixin):
"name": _("Timetable"),
}
)
if (
user.has_perm("core.change_group")
or Group.objects.manageable_by(self.request.user).exists()
):
if self.request.user.is_owner(user):
tab_list.append(
{
"url": reverse("core:user_groups", kwargs={"user_id": user.id}),
@@ -597,7 +591,7 @@ class UserPreferencesView(UserTabsMixin, UseFragmentsMixin, CanEditMixin, Update
return kwargs
class UserUpdateGroupView(UserPassesTestMixin, UserTabsMixin, UpdateView):
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
"""Edit a user's groups."""
model = User
@@ -607,15 +601,6 @@ class UserUpdateGroupView(UserPassesTestMixin, UserTabsMixin, UpdateView):
context_object_name = "profile"
current_tab = "groups"
def test_func(self) -> bool:
return self.request.user.is_authenticated and (
self.request.user.has_perm("core.change_group")
or Group.objects.manageable_by(self.request.user).exists()
)
def get_form_kwargs(self) -> dict[str, Any]:
return super().get_form_kwargs() | {"request_user": self.request.user}
class UserToolsView(LoginRequiredMixin, UserTabsMixin, TemplateView):
"""Displays the logged user's tools."""
@@ -190,17 +190,6 @@
>
{{ refilling_fragment }}
</div>
{% elif customer in request.barmen %}
<div class="accordion-content">
<p class="alert alert-yellow">
{% trans trimmed %}
You are able to refill AE accounts.
However, it is forbidden to self-refill on a counter.
To refill your account, please ask to another barman,
or do it in the eboutic.
{% endtrans %}
</p>
</div>
{% else %}
<div class="accordion-content">
<p class="alert alert-yellow">
@@ -1,5 +1,4 @@
<form
id="counter-refill-fragment"
hx-trigger="submit"
hx-post="{{ action }}"
hx-swap="outerHTML"
+1 -33
View File
@@ -18,7 +18,7 @@ from decimal import Decimal
from typing import TYPE_CHECKING
import pytest
from bs4 import BeautifulSoup, SoupStrainer
from bs4 import BeautifulSoup
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.contrib.auth.hashers import make_password
@@ -144,24 +144,6 @@ class TestRefilling(TestFullClickBase):
),
)
def refill_form_displayed(self, customer: User | Customer | None = None) -> bool:
"""Assert the click interface is displayed,
then return if it contains the refill form.
"""
if not customer:
customer = self.customer
click_res = self.client.get(
reverse(
"counter:click",
kwargs={"counter_id": self.counter.id, "user_id": customer.pk},
)
)
assert click_res.status_code == 200
soup = BeautifulSoup(
click_res.content, "lxml", parse_only=SoupStrainer(id="click-form")
)
return soup.find(id="counter-refill-fragment") is not None
def test_refilling_office_fail(self):
self.client.force_login(self.club_admin)
assert self.refill_user(self.customer, self.club_counter, 10).status_code == 403
@@ -215,22 +197,9 @@ class TestRefilling(TestFullClickBase):
def test_refilling_counter_no_board_member(self):
self.login_in_bar(barmen=self.barmen)
assert not self.refill_form_displayed()
assert self.refill_user(self.customer, self.counter, 10).status_code == 403
assert self.updated_amount(self.customer) == 0
def test_self_refill_fails(self):
"""Test that a barman cannot refill itself."""
original_amount = self.barmen.customer.amount
self.barmen.user_permissions.add(
Permission.objects.get(codename="add_refilling")
)
self.login_in_bar(barmen=self.barmen)
assert not self.refill_form_displayed(customer=self.barmen)
assert self.refill_user(self.barmen, self.counter, 10).status_code == 403
assert self.updated_amount(self.customer) == original_amount
def test_refilling_user_can_not_buy(self):
self.login_in_bar(barmen=self.barmen)
@@ -259,7 +228,6 @@ class TestRefilling(TestFullClickBase):
def test_refilling_counter_success(self):
self.login_in_bar()
assert self.refill_form_displayed()
assert self.refill_user(self.customer, self.counter, 30).status_code == 302
assert self.updated_amount(self.customer) == 30
assert self.refill_user(self.customer, self.counter, 10.1).status_code == 302
+3 -12
View File
@@ -147,9 +147,7 @@ class CounterClick(
}
def dispatch(self, request, *args, **kwargs):
self.customer = get_object_or_404(
Customer.objects.select_related("user"), user_id=self.kwargs["user_id"]
)
self.customer = get_object_or_404(Customer, user_id=self.kwargs["user_id"])
obj: Counter = self.get_object()
if not self.customer.can_buy or self.customer.user.is_banned_counter:
@@ -280,11 +278,7 @@ class CounterClick(
res["student_card_fragment"] = StudentCardFormFragment.as_fragment()(
self.request, customer=self.customer
)
if self.object.can_refill and self.customer.user not in self.request.barmen:
# The counter must a bar with a barman allowed to refill.
# However, a barman, even with the required permission,
# cannot refill itself, which means the refilling process always
# implies two persons (in order to prevent fraud and genuine errors).
if self.object.can_refill:
res["refilling_fragment"] = RefillingCreateView.as_fragment()(
self.request, customer=self.customer, counter=self.object
)
@@ -318,9 +312,7 @@ class RefillingCreateView(FragmentMixin, CreateView):
template_name = "counter/fragments/create_refill.jinja"
def dispatch(self, request, *args, **kwargs):
self.customer: Customer = get_object_or_404(
Customer.objects.select_related("user"), pk=kwargs["customer_id"]
)
self.customer: Customer = get_object_or_404(Customer, pk=kwargs["customer_id"])
if not self.customer.can_buy:
raise Http404
@@ -329,7 +321,6 @@ class RefillingCreateView(FragmentMixin, CreateView):
if (
not is_logged_in_counter(request, counter=self.counter)
or not self.counter.can_refill
or self.customer.user in self.request.barmen
):
raise PermissionDenied
+3 -19
View File
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import transaction
from django.db.models import Count
from django.forms.models import ModelChoiceIterator, ModelChoiceIteratorValue
@@ -55,7 +54,9 @@ class CandidateForm(forms.ModelForm):
class Meta:
model = Candidature
fields = ["user", "role", "program", "election_list"]
labels = {"user": _("User to candidate")}
labels = {
"user": _("User to candidate"),
}
widgets = {
"program": MarkdownInput,
"user": AutoCompleteSelectUser,
@@ -70,23 +71,6 @@ class CandidateForm(forms.ModelForm):
if not can_edit:
self.fields["user"].widget = forms.HiddenInput()
def clean_user(self):
user = self.cleaned_data.get("user")
if (
user
and user.ban_groups.filter(
id__in=[
settings.SITH_GROUP_BANNED_RESPONSIBILITY_ID,
settings.SITH_GROUP_BANNED_SUBSCRIPTION_ID,
]
).exists()
):
raise ValidationError(
_("%(user)s is forbidden to run in a election.")
% {"user": user.get_full_name()}
)
return user
class VoteForm(forms.Form):
def __init__(self, election: Election, user: User, *args, **kwargs):
+2 -23
View File
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-12-03 08:59+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"
@@ -227,10 +227,6 @@ msgstr "L'utilisateur doit être cotisant pour faire partie d'un club"
msgid "You can not add the same user twice"
msgstr "Vous ne pouvez pas ajouter deux fois le même utilisateur"
#: club/forms.py
msgid "This user is banned from being in the board of a club"
msgstr "Cette personne a l'interdiction de rejoindre le bureau d'un club."
#: club/forms.py
msgid "You must be subscribed to join a club"
msgstr "Vous devez être cotisant pour faire partie d'un club"
@@ -1320,7 +1316,7 @@ msgstr "Nos services"
msgid "UE Guide"
msgstr "Guide des UEs"
#: com/templates/com/news_list.jinja core/views/user.py
#: com/templates/com/news_list.jinja
msgid "Timetable"
msgstr "Emploi du temps"
@@ -3841,18 +3837,6 @@ msgstr "Terminer"
msgid "Refilling"
msgstr "Rechargement"
#: counter/templates/counter/counter_click.jinja
msgid ""
"You are able to refill AE accounts. However, it is forbidden to self-refill "
"on a counter. To refill your account, please ask to another barman, or do it "
"in the eboutic."
msgstr ""
"Vous avez le droit de recharger des comptes AE."
"Cependant, le rechargement de son propre compte sur un comptoir"
"est administrativement prohibé."
"Pour recharger votre compte, veuillez demander à un autre"
"barman ou passer par l'eboutic."
#: counter/templates/counter/counter_click.jinja
msgid ""
"As a barman, you are not able to refill any account on your own. An admin "
@@ -4582,11 +4566,6 @@ msgstr "Vous avez sélectionné trop de candidats."
msgid "User to candidate"
msgstr "Utilisateur se présentant"
#: election/forms.py
#, python-format
msgid "%(user)s is forbidden to run in a election."
msgstr "%(user)s n'a pas le droit de se présenter à une élection."
#: election/forms.py election/templates/election/election_detail.jinja
msgid "Blank vote"
msgstr "Vote blanc"
+1 -24
View File
@@ -4,11 +4,10 @@ from typing import TYPE_CHECKING
import pytest
from django.contrib.auth.models import Permission
from django.urls import reverse
from django.utils.timezone import localdate, localtime
from django.utils.timezone import localtime
from model_bakery import baker
from pytest_django.asserts import assertRedirects
from club.models import ClubRole, Membership
from core.baker_recipes import subscriber_user
from core.models import BanGroup, User, UserBan
from counter.models import Counter
@@ -67,28 +66,6 @@ def test_ban_counter_ends_barmanship():
assert not user.counters.exists()
@pytest.mark.django_db
def test_ban_responsability_ends_board_memberships():
user = subscriber_user.make()
roles = baker.make(ClubRole, is_board=iter([False, True]), _quantity=2)
membership = baker.make(
Membership, role=roles[0], club=roles[0].club, user=user, end_date=None
)
board_membership = baker.make(
Membership, role=roles[1], club=roles[1].club, user=user, end_date=None
)
UserBan.objects.create(
user=user,
ban_group_id=settings.SITH_GROUP_BANNED_RESPONSIBILITY_ID,
reason="ban responsabilités",
)
# only the board membership should be concluded
membership.refresh_from_db()
assert not membership.end_date
board_membership.refresh_from_db()
assert board_membership.end_date == localdate()
@pytest.mark.django_db
def test_remove_ban(client: Client, operator: User):
client.force_login(operator)
-3
View File
@@ -403,9 +403,6 @@ SITH_GROUP_BANNED_COUNTER_ID = env.int("SITH_GROUP_BANNED_COUNTER_ID", default=1
SITH_GROUP_BANNED_SUBSCRIPTION_ID = env.int(
"SITH_GROUP_BANNED_SUBSCRIPTION_ID", default=14
)
SITH_GROUP_BANNED_RESPONSIBILITY_ID = env.int(
"SITH_GROUP_BANNED_RESPONSIBILITY_ID", default=15
)
SITH_CLUB_REFOUND_ID = env.int("SITH_CLUB_REFOUND_ID", default=89)
SITH_COUNTER_REFOUND_ID = env.int("SITH_COUNTER_REFOUND_ID", default=38)