mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Apply review comments
This commit is contained in:
parent
66e5ef64fd
commit
a0eb53a607
@ -652,13 +652,12 @@ class Counter(models.Model):
|
|||||||
)["total"]
|
)["total"]
|
||||||
|
|
||||||
def customer_is_barman(self, customer: Customer | User) -> bool:
|
def customer_is_barman(self, customer: Customer | User) -> bool:
|
||||||
"""Check if current counter is a `bar` and that the customer is on the barmen_list
|
"""Check if this counter is a `bar` and if the customer is currently logged in.
|
||||||
|
This is useful to compute special prices."""
|
||||||
|
|
||||||
This is useful to compute special prices"""
|
# Customer and User are two different tables,
|
||||||
if isinstance(customer, Customer):
|
# but they share the same primary key
|
||||||
customer: User = customer.user
|
return self.type == "BAR" and any(b.pk == customer.pk for b in self.barmen_list)
|
||||||
|
|
||||||
return self.type == "BAR" and customer in self.barmen_list
|
|
||||||
|
|
||||||
|
|
||||||
class RefillingQuerySet(models.QuerySet):
|
class RefillingQuerySet(models.QuerySet):
|
||||||
|
@ -417,7 +417,7 @@ class RefillingCreateView(FormView):
|
|||||||
def get_template_data(
|
def get_template_data(
|
||||||
cls, customer: Customer, *, form_instance: form_class | None = None
|
cls, customer: Customer, *, form_instance: form_class | None = None
|
||||||
) -> FormFragmentTemplateData[form_class]:
|
) -> FormFragmentTemplateData[form_class]:
|
||||||
return FormFragmentTemplateData[cls.form_class](
|
return FormFragmentTemplateData(
|
||||||
form=form_instance if form_instance else cls.form_class(),
|
form=form_instance if form_instance else cls.form_class(),
|
||||||
template=cls.template_name,
|
template=cls.template_name,
|
||||||
context={
|
context={
|
||||||
|
@ -73,7 +73,7 @@ class StudentCardFormView(FormView):
|
|||||||
cls, customer: Customer, *, form_instance: form_class | None = None
|
cls, customer: Customer, *, form_instance: form_class | None = None
|
||||||
) -> FormFragmentTemplateData[form_class]:
|
) -> FormFragmentTemplateData[form_class]:
|
||||||
"""Get necessary data to pre-render the fragment"""
|
"""Get necessary data to pre-render the fragment"""
|
||||||
return FormFragmentTemplateData[cls.form_class](
|
return FormFragmentTemplateData(
|
||||||
form=form_instance if form_instance else cls.form_class(),
|
form=form_instance if form_instance else cls.form_class(),
|
||||||
template=cls.template_name,
|
template=cls.template_name,
|
||||||
context={
|
context={
|
||||||
|
Loading…
Reference in New Issue
Block a user