mirror of
https://github.com/ae-utbm/sith.git
synced 2025-08-24 09:51:07 +00:00
Improve eboutic readability
This commit is contained in:
@@ -133,28 +133,30 @@ class EbouticMainView(LoginRequiredMixin, FormView):
|
|||||||
context["products"] = self.products
|
context["products"] = self.products
|
||||||
context["customer_amount"] = self.request.user.account_balance
|
context["customer_amount"] = self.request.user.account_balance
|
||||||
|
|
||||||
|
purchases = (
|
||||||
|
Customer.objects.filter(pk=self.customer.pk)
|
||||||
|
.annotate(
|
||||||
|
last_refill=Subquery(
|
||||||
|
Refilling.objects.filter(
|
||||||
|
counter__type="EBOUTIC", customer_id=self.customer.pk
|
||||||
|
)
|
||||||
|
.order_by("-date")
|
||||||
|
.values("date")[:1]
|
||||||
|
),
|
||||||
|
last_purchase=Subquery(
|
||||||
|
Selling.objects.filter(
|
||||||
|
counter__type="EBOUTIC", customer_id=self.customer.pk
|
||||||
|
)
|
||||||
|
.order_by("-date")
|
||||||
|
.values("date")[:1]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.values_list("last_refill", "last_purchase")
|
||||||
|
)[0]
|
||||||
|
|
||||||
purchase_times = [
|
purchase_times = [
|
||||||
int(purchase.timestamp() * 1000)
|
int(purchase.timestamp() * 1000)
|
||||||
for purchase in (
|
for purchase in purchases
|
||||||
Customer.objects.filter(pk=self.customer.pk)
|
|
||||||
.annotate(
|
|
||||||
last_refill=Subquery(
|
|
||||||
Refilling.objects.filter(
|
|
||||||
counter__type="EBOUTIC", customer_id=self.customer.pk
|
|
||||||
)
|
|
||||||
.order_by("-date")
|
|
||||||
.values("date")[:1]
|
|
||||||
),
|
|
||||||
last_purchase=Subquery(
|
|
||||||
Selling.objects.filter(
|
|
||||||
counter__type="EBOUTIC", customer_id=self.customer.pk
|
|
||||||
)
|
|
||||||
.order_by("-date")
|
|
||||||
.values("date")[:1]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.values("last_refill", "last_purchase")
|
|
||||||
)[0].values()
|
|
||||||
if purchase is not None
|
if purchase is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user