mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-18 04:03:22 +00:00
Add of restriction for refilling
This commit is contained in:
parent
757ff7ead7
commit
c6caf5dbce
@ -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):
|
||||||
"""
|
"""
|
||||||
|
@ -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) }}">
|
||||||
|
@ -483,7 +483,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
|||||||
]:
|
]:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_product(self, pid):
|
def get_product(self, pid):
|
||||||
return Product.objects.filter(pk=int(pid)).first()
|
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["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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user