Add of restriction for refilling

This commit is contained in:
lsacienne 2022-04-20 14:01:33 +02:00
parent 757ff7ead7
commit c6caf5dbce
No known key found for this signature in database
GPG Key ID: 5B1939A93F7A6F48
3 changed files with 12 additions and 3 deletions

View File

@ -39,7 +39,7 @@ import os
import base64 import base64
import datetime import datetime
from club.models import Club from club.models import Club, Membership
from accounting.models import CurrencyField from accounting.models import CurrencyField
from core.models import Group, User, Notification from core.models import Group, User, Notification
from subscription.models import Subscription from subscription.models import Subscription
@ -342,6 +342,14 @@ class Counter(models.Model):
""" """
return [b.id for b in self.get_barmen_list()] 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): class Refilling(models.Model):
""" """

View File

@ -107,7 +107,7 @@
<input type="submit" value="{% trans %}Cancel{% endtrans %}" /> <input type="submit" value="{% trans %}Cancel{% endtrans %}" />
</form> </form>
</div> </div>
{% if counter.type == 'BAR' %} {% if (counter.type == 'BAR' and barmens_can_refill) %}
<h5>{% trans %}Refilling{% endtrans %}</h5> <h5>{% trans %}Refilling{% endtrans %}</h5>
<div> <div>
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}"> <form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">

View File

@ -751,6 +751,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
kwargs["basket_total"] = self.sum_basket(self.request) kwargs["basket_total"] = self.sum_basket(self.request)
kwargs["refill_form"] = self.refill_form or RefillForm() kwargs["refill_form"] = self.refill_form or RefillForm()
kwargs["student_card_max_uid_size"] = StudentCard.UID_SIZE kwargs["student_card_max_uid_size"] = StudentCard.UID_SIZE
kwargs["barmens_can_refill"] = self.object.can_refill()
return kwargs return kwargs