mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
Fix counter if no date of birth
This commit is contained in:
@ -39,6 +39,9 @@
|
||||
{% if request.session['not_allowed'] %}
|
||||
<p><strong>{% trans %}Not allowed for that product{% endtrans %}</strong></p>
|
||||
{% endif %}
|
||||
{% if request.session['no_age'] %}
|
||||
<p><strong>{% trans %}No date of birth provided{% endtrans %}</strong></p>
|
||||
{% endif %}
|
||||
{% if request.session['not_enough'] %}
|
||||
<p><strong>{% trans %}Not enough money{% endtrans %}</strong></p>
|
||||
{% endif %}
|
||||
|
@ -121,9 +121,10 @@ class CounterClick(DetailView):
|
||||
if 'basket' not in request.session.keys(): # Init the basket session entry
|
||||
request.session['basket'] = {}
|
||||
request.session['basket_total'] = 0
|
||||
request.session['not_enough'] = False
|
||||
request.session['not_enough'] = False # Reset every variable
|
||||
request.session['too_young'] = False
|
||||
request.session['not_allowed'] = False
|
||||
request.session['no_age'] = False
|
||||
self.refill_form = None
|
||||
ret = super(CounterClick, self).get(request, *args, **kwargs)
|
||||
if ((self.object.type != "BAR" and not request.user.is_authenticated()) or
|
||||
@ -144,9 +145,10 @@ class CounterClick(DetailView):
|
||||
if 'basket' not in request.session.keys():
|
||||
request.session['basket'] = {}
|
||||
request.session['basket_total'] = 0
|
||||
request.session['not_enough'] = False
|
||||
request.session['not_enough'] = False # Reset every variable
|
||||
request.session['too_young'] = False
|
||||
request.session['not_allowed'] = False
|
||||
request.session['no_age'] = False
|
||||
if self.object.type != "BAR":
|
||||
self.operator = request.user
|
||||
elif self.is_barman_price():
|
||||
@ -228,7 +230,10 @@ class CounterClick(DetailView):
|
||||
if self.customer.amount < (total + q*float(price)): # Check for enough money
|
||||
request.session['not_enough'] = True
|
||||
return False
|
||||
if self.customer.user.get_age() < product.limit_age: # Check if affordable
|
||||
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
||||
request.session['no_age'] = True
|
||||
return False
|
||||
if self.customer.user.date_of_birth and self.customer.user.get_age() < product.limit_age: # Check if affordable
|
||||
request.session['too_young'] = True
|
||||
return False
|
||||
if pid in request.session['basket']: # Add if already in basket
|
||||
|
Reference in New Issue
Block a user