apply review comment

This commit is contained in:
thomas girod
2024-08-05 10:46:15 +02:00
parent a5e4db99fb
commit a637742bb0
4 changed files with 12 additions and 12 deletions

View File

@ -6,7 +6,7 @@ from django.urls import resolve
from counter.models import Counter
def sent_from_logged_counter(request: HttpRequest) -> bool:
def is_logged_in_counter(request: HttpRequest) -> bool:
"""Check if the request is sent from a device logged to a counter.
The request must also be sent within the frame of a counter's activity.

View File

@ -80,7 +80,7 @@ from counter.models import (
Selling,
StudentCard,
)
from counter.utils import sent_from_logged_counter
from counter.utils import is_logged_in_counter
class CounterAdminMixin(View):
@ -904,7 +904,7 @@ class RefillingDeleteView(DeleteView):
self.object = self.get_object()
if timezone.now() - self.object.date <= timedelta(
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
) and sent_from_logged_counter(request):
) and is_logged_in_counter(request):
self.success_url = reverse(
"counter:details", kwargs={"counter_id": self.object.counter.id}
)
@ -929,7 +929,7 @@ class SellingDeleteView(DeleteView):
self.object = self.get_object()
if timezone.now() - self.object.date <= timedelta(
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
) and sent_from_logged_counter(request):
) and is_logged_in_counter(request):
self.success_url = reverse(
"counter:details", kwargs={"counter_id": self.object.counter.id}
)
@ -1164,7 +1164,7 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
def dispatch(self, request, *args, **kwargs):
"""We have here again a very particular right handling."""
self.object = self.get_object()
if sent_from_logged_counter(request) and self.object.barmen_list:
if is_logged_in_counter(request) and self.object.barmen_list:
return super().dispatch(request, *args, **kwargs)
return HttpResponseRedirect(
reverse("counter:details", kwargs={"counter_id": self.object.id})
@ -1197,7 +1197,7 @@ class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
def dispatch(self, request, *args, **kwargs):
"""We have here again a very particular right handling."""
self.object = self.get_object()
if sent_from_logged_counter(request) and self.object.barmen_list:
if is_logged_in_counter(request) and self.object.barmen_list:
return super().dispatch(request, *args, **kwargs)
return HttpResponseRedirect(
reverse("counter:details", kwargs={"counter_id": self.object.id})