mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-23 00:01:16 +00:00
Fix get_operator on non bar counters and better display of counter with no products
This commit is contained in:
parent
b8430adc50
commit
5079938a5b
@ -148,6 +148,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="products">
|
<div id="products">
|
||||||
|
{% if not products %}
|
||||||
|
<div class="alert alert-red">
|
||||||
|
{% trans %}No products available on this counter for this user{% endtrans %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for category in categories.keys() -%}
|
{% for category in categories.keys() -%}
|
||||||
<li><a href="#cat_{{ category|slugify }}">{{ category }}</a></li>
|
<li><a href="#cat_{{ category|slugify }}">{{ category }}</a></li>
|
||||||
@ -175,6 +180,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
@ -29,6 +29,7 @@ from django.urls import reverse_lazy
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import FormView
|
from django.views.generic import FormView
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
|
from ninja.main import HttpRequest
|
||||||
|
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from core.utils import FormFragmentTemplateData
|
from core.utils import FormFragmentTemplateData
|
||||||
@ -40,7 +41,9 @@ from counter.views.mixins import CounterTabsMixin
|
|||||||
from counter.views.student_card import StudentCardFormView
|
from counter.views.student_card import StudentCardFormView
|
||||||
|
|
||||||
|
|
||||||
def get_operator(counter: Counter, customer: Customer) -> User:
|
def get_operator(request: HttpRequest, counter: Counter, customer: Customer) -> User:
|
||||||
|
if counter.type != "BAR":
|
||||||
|
return request.user
|
||||||
if counter.customer_is_barman(customer):
|
if counter.customer_is_barman(customer):
|
||||||
return customer.user
|
return customer.user
|
||||||
return counter.get_random_barman()
|
return counter.get_random_barman()
|
||||||
@ -181,7 +184,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, SingleObjectMixin, FormView):
|
|||||||
if len(formset) == 0:
|
if len(formset) == 0:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
operator = get_operator(self.object, self.customer)
|
operator = get_operator(self.request, self.object, self.customer)
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
self.request.session["last_basket"] = []
|
self.request.session["last_basket"] = []
|
||||||
|
|
||||||
@ -291,7 +294,7 @@ class RefillingCreateView(FormView):
|
|||||||
if not self.counter.can_refill():
|
if not self.counter.can_refill():
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
self.operator = get_operator(self.counter, self.customer)
|
self.operator = get_operator(request, self.counter, self.customer)
|
||||||
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user