mirror of
https://github.com/ae-utbm/sith.git
synced 2026-12-04 06:42:47 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
702524d77d | ||
|
|
ebb43658e1 | ||
|
|
6bb1a049c6 | ||
|
|
96800a249d |
No files matched your search
+30
-2
@@ -25,6 +25,7 @@ import itertools
|
|||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.conf import settings
|
||||||
from django.db.models import Exists, OuterRef, Q, QuerySet
|
from django.db.models import Exists, OuterRef, Q, QuerySet
|
||||||
from django.db.models.functions import Lower
|
from django.db.models.functions import Lower
|
||||||
from django.forms.models import ModelChoiceField, ModelChoiceIterator
|
from django.forms.models import ModelChoiceField, ModelChoiceIterator
|
||||||
@@ -182,7 +183,12 @@ class ClubOldMemberForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class ClubMemberForm(forms.ModelForm):
|
class ClubMemberForm(forms.ModelForm):
|
||||||
"""Form to add a member to the club, as a board member."""
|
"""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.
|
||||||
|
"""
|
||||||
|
|
||||||
error_css_class = "error"
|
error_css_class = "error"
|
||||||
required_css_class = "required"
|
required_css_class = "required"
|
||||||
@@ -247,9 +253,29 @@ class ClubAddMemberForm(ClubMemberForm):
|
|||||||
)
|
)
|
||||||
return user
|
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):
|
class JoinClubForm(ClubMemberForm):
|
||||||
"""Form to join a club."""
|
"""Form to join a club.
|
||||||
|
|
||||||
|
Only member roles can be obtained through this form.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, club: Club, request_user: User, **kwargs):
|
def __init__(self, *args, club: Club, request_user: User, **kwargs):
|
||||||
super().__init__(*args, club=club, request_user=request_user, **kwargs)
|
super().__init__(*args, club=club, request_user=request_user, **kwargs)
|
||||||
@@ -261,6 +287,8 @@ class JoinClubForm(ClubMemberForm):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
"""Check that the user is subscribed and isn't already in the club."""
|
"""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:
|
if not self.request_user.is_subscribed:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
_("You must be subscribed to join a club"), code="invalid"
|
_("You must be subscribed to join a club"), code="invalid"
|
||||||
|
|||||||
+12
-6
@@ -421,18 +421,24 @@ class MembershipQuerySet(models.QuerySet):
|
|||||||
"""Remove users from club groups they are no more in
|
"""Remove users from club groups they are no more in
|
||||||
and add them in the club groups they should be in.
|
and add them in the club groups they should be in.
|
||||||
|
|
||||||
Be aware that this adds three db queries :
|
Be aware that this adds four db queries (on top of the UPDATE query) :
|
||||||
|
|
||||||
- one to retrieve the updated memberships
|
- two to retrieve the updated memberships
|
||||||
- one to perform group removal
|
- one to perform group removal
|
||||||
- and one to perform group attribution.
|
- and one to perform group attribution.
|
||||||
"""
|
"""
|
||||||
nb_rows = super().update(**kwargs)
|
memberships = set(self.values_list("id", flat=True))
|
||||||
if nb_rows == 0:
|
if not memberships:
|
||||||
# if no row was affected, no need to edit club groups
|
# if there is no selected membership,there is nothing to do
|
||||||
return 0
|
return 0
|
||||||
|
nb_rows = super().update(**kwargs)
|
||||||
|
|
||||||
memberships = set(self.select_related("club"))
|
# 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")
|
||||||
|
)
|
||||||
# delete all User-Group relations and recreate the necessary ones
|
# delete all User-Group relations and recreate the necessary ones
|
||||||
Membership._remove_club_groups(memberships)
|
Membership._remove_club_groups(memberships)
|
||||||
Membership._add_club_groups(memberships)
|
Membership._add_club_groups(memberships)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
@@ -17,7 +18,7 @@ from club.forms import ClubAddMemberForm, JoinClubForm
|
|||||||
from club.models import Club, ClubRole, Membership
|
from club.models import Club, ClubRole, Membership
|
||||||
from club.tests.base import TestClub
|
from club.tests.base import TestClub
|
||||||
from core.baker_recipes import subscriber_user
|
from core.baker_recipes import subscriber_user
|
||||||
from core.models import AnonymousUser, Group, User
|
from core.models import AnonymousUser, Group, User, UserBan
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
@@ -386,6 +387,25 @@ class TestMembership(TestClub):
|
|||||||
"user": ["Vous ne pouvez pas ajouter deux fois le même utilisateur"]
|
"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):
|
def test_add_other_member_forbidden(self):
|
||||||
non_member = subscriber_user.make()
|
non_member = subscriber_user.make()
|
||||||
simple_member = baker.make(
|
simple_member = baker.make(
|
||||||
|
|||||||
@@ -1006,6 +1006,7 @@ class Command(BaseCommand):
|
|||||||
BanGroup.objects.create(name="Banned from buying alcohol", description="")
|
BanGroup.objects.create(name="Banned from buying alcohol", description="")
|
||||||
BanGroup.objects.create(name="Banned from counters", description="")
|
BanGroup.objects.create(name="Banned from counters", description="")
|
||||||
BanGroup.objects.create(name="Banned to subscribe", description="")
|
BanGroup.objects.create(name="Banned to subscribe", description="")
|
||||||
|
BanGroup.objects.create(name="Responsibility ban", description="")
|
||||||
|
|
||||||
def _create_elections(
|
def _create_elections(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -775,6 +775,8 @@ class UserBan(models.Model):
|
|||||||
settings.SITH_GROUP_BANNED_SUBSCRIPTION_ID,
|
settings.SITH_GROUP_BANNED_SUBSCRIPTION_ID,
|
||||||
]:
|
]:
|
||||||
self.user.counters.clear()
|
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)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,17 @@
|
|||||||
>
|
>
|
||||||
{{ refilling_fragment }}
|
{{ refilling_fragment }}
|
||||||
</div>
|
</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 %}
|
{% else %}
|
||||||
<div class="accordion-content">
|
<div class="accordion-content">
|
||||||
<p class="alert alert-yellow">
|
<p class="alert alert-yellow">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<form
|
<form
|
||||||
|
id="counter-refill-fragment"
|
||||||
hx-trigger="submit"
|
hx-trigger="submit"
|
||||||
hx-post="{{ action }}"
|
hx-post="{{ action }}"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from decimal import Decimal
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup, SoupStrainer
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
@@ -144,6 +144,24 @@ 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):
|
def test_refilling_office_fail(self):
|
||||||
self.client.force_login(self.club_admin)
|
self.client.force_login(self.club_admin)
|
||||||
assert self.refill_user(self.customer, self.club_counter, 10).status_code == 403
|
assert self.refill_user(self.customer, self.club_counter, 10).status_code == 403
|
||||||
@@ -197,9 +215,22 @@ class TestRefilling(TestFullClickBase):
|
|||||||
|
|
||||||
def test_refilling_counter_no_board_member(self):
|
def test_refilling_counter_no_board_member(self):
|
||||||
self.login_in_bar(barmen=self.barmen)
|
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.refill_user(self.customer, self.counter, 10).status_code == 403
|
||||||
assert self.updated_amount(self.customer) == 0
|
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):
|
def test_refilling_user_can_not_buy(self):
|
||||||
self.login_in_bar(barmen=self.barmen)
|
self.login_in_bar(barmen=self.barmen)
|
||||||
|
|
||||||
@@ -228,6 +259,7 @@ class TestRefilling(TestFullClickBase):
|
|||||||
def test_refilling_counter_success(self):
|
def test_refilling_counter_success(self):
|
||||||
self.login_in_bar()
|
self.login_in_bar()
|
||||||
|
|
||||||
|
assert self.refill_form_displayed()
|
||||||
assert self.refill_user(self.customer, self.counter, 30).status_code == 302
|
assert self.refill_user(self.customer, self.counter, 30).status_code == 302
|
||||||
assert self.updated_amount(self.customer) == 30
|
assert self.updated_amount(self.customer) == 30
|
||||||
assert self.refill_user(self.customer, self.counter, 10.1).status_code == 302
|
assert self.refill_user(self.customer, self.counter, 10.1).status_code == 302
|
||||||
|
|||||||
+12
-3
@@ -147,7 +147,9 @@ class CounterClick(
|
|||||||
}
|
}
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.customer = get_object_or_404(Customer, user_id=self.kwargs["user_id"])
|
self.customer = get_object_or_404(
|
||||||
|
Customer.objects.select_related("user"), user_id=self.kwargs["user_id"]
|
||||||
|
)
|
||||||
obj: Counter = self.get_object()
|
obj: Counter = self.get_object()
|
||||||
|
|
||||||
if not self.customer.can_buy or self.customer.user.is_banned_counter:
|
if not self.customer.can_buy or self.customer.user.is_banned_counter:
|
||||||
@@ -278,7 +280,11 @@ class CounterClick(
|
|||||||
res["student_card_fragment"] = StudentCardFormFragment.as_fragment()(
|
res["student_card_fragment"] = StudentCardFormFragment.as_fragment()(
|
||||||
self.request, customer=self.customer
|
self.request, customer=self.customer
|
||||||
)
|
)
|
||||||
if self.object.can_refill:
|
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).
|
||||||
res["refilling_fragment"] = RefillingCreateView.as_fragment()(
|
res["refilling_fragment"] = RefillingCreateView.as_fragment()(
|
||||||
self.request, customer=self.customer, counter=self.object
|
self.request, customer=self.customer, counter=self.object
|
||||||
)
|
)
|
||||||
@@ -312,7 +318,9 @@ class RefillingCreateView(FragmentMixin, CreateView):
|
|||||||
template_name = "counter/fragments/create_refill.jinja"
|
template_name = "counter/fragments/create_refill.jinja"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.customer: Customer = get_object_or_404(Customer, pk=kwargs["customer_id"])
|
self.customer: Customer = get_object_or_404(
|
||||||
|
Customer.objects.select_related("user"), pk=kwargs["customer_id"]
|
||||||
|
)
|
||||||
if not self.customer.can_buy:
|
if not self.customer.can_buy:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
@@ -321,6 +329,7 @@ class RefillingCreateView(FragmentMixin, CreateView):
|
|||||||
if (
|
if (
|
||||||
not is_logged_in_counter(request, counter=self.counter)
|
not is_logged_in_counter(request, counter=self.counter)
|
||||||
or not self.counter.can_refill
|
or not self.counter.can_refill
|
||||||
|
or self.customer.user in self.request.barmen
|
||||||
):
|
):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
|
|||||||
+19
-3
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from django.forms.models import ModelChoiceIterator, ModelChoiceIteratorValue
|
from django.forms.models import ModelChoiceIterator, ModelChoiceIteratorValue
|
||||||
@@ -54,9 +55,7 @@ class CandidateForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Candidature
|
model = Candidature
|
||||||
fields = ["user", "role", "program", "election_list"]
|
fields = ["user", "role", "program", "election_list"]
|
||||||
labels = {
|
labels = {"user": _("User to candidate")}
|
||||||
"user": _("User to candidate"),
|
|
||||||
}
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"program": MarkdownInput,
|
"program": MarkdownInput,
|
||||||
"user": AutoCompleteSelectUser,
|
"user": AutoCompleteSelectUser,
|
||||||
@@ -71,6 +70,23 @@ class CandidateForm(forms.ModelForm):
|
|||||||
if not can_edit:
|
if not can_edit:
|
||||||
self.fields["user"].widget = forms.HiddenInput()
|
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):
|
class VoteForm(forms.Form):
|
||||||
def __init__(self, election: Election, user: User, *args, **kwargs):
|
def __init__(self, election: Election, user: User, *args, **kwargs):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2026-11-14 13:59+0100\n"
|
"POT-Creation-Date: 2026-12-03 08:59+0100\n"
|
||||||
"PO-Revision-Date: 2016-07-18\n"
|
"PO-Revision-Date: 2016-07-18\n"
|
||||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||||
@@ -227,6 +227,10 @@ msgstr "L'utilisateur doit être cotisant pour faire partie d'un club"
|
|||||||
msgid "You can not add the same user twice"
|
msgid "You can not add the same user twice"
|
||||||
msgstr "Vous ne pouvez pas ajouter deux fois le même utilisateur"
|
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
|
#: club/forms.py
|
||||||
msgid "You must be subscribed to join a club"
|
msgid "You must be subscribed to join a club"
|
||||||
msgstr "Vous devez être cotisant pour faire partie d'un club"
|
msgstr "Vous devez être cotisant pour faire partie d'un club"
|
||||||
@@ -1316,7 +1320,7 @@ msgstr "Nos services"
|
|||||||
msgid "UE Guide"
|
msgid "UE Guide"
|
||||||
msgstr "Guide des UEs"
|
msgstr "Guide des UEs"
|
||||||
|
|
||||||
#: com/templates/com/news_list.jinja
|
#: com/templates/com/news_list.jinja core/views/user.py
|
||||||
msgid "Timetable"
|
msgid "Timetable"
|
||||||
msgstr "Emploi du temps"
|
msgstr "Emploi du temps"
|
||||||
|
|
||||||
@@ -3837,6 +3841,18 @@ msgstr "Terminer"
|
|||||||
msgid "Refilling"
|
msgid "Refilling"
|
||||||
msgstr "Rechargement"
|
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
|
#: counter/templates/counter/counter_click.jinja
|
||||||
msgid ""
|
msgid ""
|
||||||
"As a barman, you are not able to refill any account on your own. An admin "
|
"As a barman, you are not able to refill any account on your own. An admin "
|
||||||
@@ -4566,6 +4582,11 @@ msgstr "Vous avez sélectionné trop de candidats."
|
|||||||
msgid "User to candidate"
|
msgid "User to candidate"
|
||||||
msgstr "Utilisateur se présentant"
|
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
|
#: election/forms.py election/templates/election/election_detail.jinja
|
||||||
msgid "Blank vote"
|
msgid "Blank vote"
|
||||||
msgstr "Vote blanc"
|
msgstr "Vote blanc"
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ from typing import TYPE_CHECKING
|
|||||||
import pytest
|
import pytest
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.timezone import localtime
|
from django.utils.timezone import localdate, localtime
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
from pytest_django.asserts import assertRedirects
|
from pytest_django.asserts import assertRedirects
|
||||||
|
|
||||||
|
from club.models import ClubRole, Membership
|
||||||
from core.baker_recipes import subscriber_user
|
from core.baker_recipes import subscriber_user
|
||||||
from core.models import BanGroup, User, UserBan
|
from core.models import BanGroup, User, UserBan
|
||||||
from counter.models import Counter
|
from counter.models import Counter
|
||||||
@@ -66,6 +67,28 @@ def test_ban_counter_ends_barmanship():
|
|||||||
assert not user.counters.exists()
|
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
|
@pytest.mark.django_db
|
||||||
def test_remove_ban(client: Client, operator: User):
|
def test_remove_ban(client: Client, operator: User):
|
||||||
client.force_login(operator)
|
client.force_login(operator)
|
||||||
|
|||||||
@@ -403,6 +403,9 @@ 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 = env.int(
|
||||||
"SITH_GROUP_BANNED_SUBSCRIPTION_ID", default=14
|
"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_CLUB_REFOUND_ID = env.int("SITH_CLUB_REFOUND_ID", default=89)
|
||||||
SITH_COUNTER_REFOUND_ID = env.int("SITH_COUNTER_REFOUND_ID", default=38)
|
SITH_COUNTER_REFOUND_ID = env.int("SITH_COUNTER_REFOUND_ID", default=38)
|
||||||
|
|||||||
Reference in new issue
Block a user