Verified Commit c6caf5db authored by Alexandre | L'Sacienne's avatar Alexandre | L'Sacienne
Browse files

Add of restriction for refilling

parent 757ff7ea
Pipeline #2481 failed with stage
in 32 minutes and 29 seconds
......@@ -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):
"""
......
......@@ -107,7 +107,7 @@
<input type="submit" value="{% trans %}Cancel{% endtrans %}" />
</form>
</div>
{% if counter.type == 'BAR' %}
{% if (counter.type == 'BAR' and barmens_can_refill) %}
<h5>{% trans %}Refilling{% endtrans %}</h5>
<div>
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment