diff --git a/counter/models.py b/counter/models.py index 3d3fef5b..6ec5796b 100644 --- a/counter/models.py +++ b/counter/models.py @@ -39,7 +39,7 @@ import os import base64 import datetime -from club.models import Club +from club.models import Club, Membership from accounting.models import CurrencyField from core.models import Group, User, Notification from subscription.models import Subscription @@ -342,6 +342,14 @@ class Counter(models.Model): """ return [b.id for b in self.get_barmen_list()] + def can_refill(self): + is_ae_member = False + ae = Club.objects.get(unix_name="ae") + for barman in self.get_barmen_list(): + if Membership.objects.filter(club=ae, user=barman): + is_ae_member = True + return is_ae_member + class Refilling(models.Model): """ diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index 06cb191b..b9238b89 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -107,7 +107,7 @@ - {% if counter.type == 'BAR' %} + {% if (counter.type == 'BAR' and barmens_can_refill) %}
{% trans %}Refilling{% endtrans %}
diff --git a/counter/views.py b/counter/views.py index e03831e1..2a46dc02 100644 --- a/counter/views.py +++ b/counter/views.py @@ -483,7 +483,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView): ]: return True else: - return False + return False def get_product(self, pid): return Product.objects.filter(pk=int(pid)).first() @@ -751,6 +751,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView): kwargs["basket_total"] = self.sum_basket(self.request) kwargs["refill_form"] = self.refill_form or RefillForm() kwargs["student_card_max_uid_size"] = StudentCard.UID_SIZE + kwargs["barmens_can_refill"] = self.object.can_refill() return kwargs