forbid minors from selling alcohol

This commit is contained in:
imperosol committed 2026-11-12 15:49:31 +01:00
1 parent e45b4eb9e0
commit 01112a89aa
3 files changed
+45 -2

No files matched your search

+26 -1
View File
@@ -405,7 +405,7 @@ class TestCounterClick(TestFullClickBase):
self.assertRedirects(res, self.counter.get_absolute_url())
assert self.updated_amount(self.customer) == Decimal(8)
def test_click_alcool_unauthorized(self):
def test_click_alcohol_unauthorized(self):
self.login_in_bar()
for user in [self.underage_customer, self.banned_alcohol_customer]:
@@ -423,6 +423,31 @@ class TestCounterClick(TestFullClickBase):
assert self.updated_amount(user) == Decimal(7)
def test_click_no_alcohol_if_minor_barman(self):
"""Test that no age restricted product can be sold if the barman is minor."""
set_age(self.barmen, 17)
self.login_in_bar(self.barmen)
res = self.client.get(
reverse(
"counter:click",
kwargs={"counter_id": self.counter.id, "user_id": self.customer.id},
)
)
assert res.status_code == 200
messages = list(get_messages(res.wsgi_request))
assert len(messages) == 1
assert messages[0].level == DEFAULT_LEVELS["WARNING"]
assert messages[0].message == (
"Un mineur est barman sur cet appareil, "
"vous ne pouvez donc pas vendre d'alcool actuellement."
)
assert res.context_data["prices"] == [
self.gift,
self.snack,
self.cons,
self.dcons,
]
def test_click_unauthorized_customer(self):
self.login_in_bar()
+11
View File
@@ -111,6 +111,17 @@ class CounterClick(
return redirect(obj) # Redirect to counter
self.prices = list(obj.get_prices_for(self.customer))
if any(user.age < 18 for user in request.barmen):
filtered = [p for p in self.prices if p.product.limit_age < 18]
if len(filtered) != len(self.prices):
self.prices = filtered
messages.warning(
request,
_(
"A minor is barman on this on this device, "
"so you cannot currently sell alcohol."
),
)
return super().dispatch(request, *args, **kwargs)
+8 -1
View File
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-10 13:16+0100\n"
"POT-Creation-Date: 2026-11-12 15:32+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"
@@ -4339,6 +4339,13 @@ msgstr "Nombre de chèque"
msgid "You cannot click users on this counter"
msgstr "Vous ne pouvez pas cliquer des gens sur ce comptoir"
#: counter/views/click.py
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."
#: counter/views/eticket.py
msgid "people(s)"
msgstr "personne(s)"