mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-28 20:33:00 +02:00
Add waiting lists interfaces
Signed-off-by: Emmy D'ANELLO <ynerant@crans.org>
This commit is contained in:
@ -42,6 +42,10 @@
|
||||
{% for food in sheet.food_set.all %}
|
||||
<li{% if not food.available %} class="text-danger" style="text-decoration: line-through !important;" title="{% trans "This product is unavailable." %}"{% endif %}>
|
||||
{{ food }} ({{ food.price|pretty_money }})
|
||||
<a href="{% url 'sheets:waiting_list' pk=food.pk %}" class="badge badge-primary">
|
||||
<i class="fa fa-list"></i>
|
||||
{% trans "Waiting list" %}
|
||||
</a>
|
||||
{% if can_change_sheet %}
|
||||
<a href="{% url 'sheets:food_update' pk=food.pk %}" class="badge badge-primary">
|
||||
<i class="fa fa-edit"></i>
|
||||
|
@ -4,7 +4,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from sheets.views import FoodCreateView, FoodUpdateView, MealCreateView, MealUpdateView, OrderView, \
|
||||
SheetCreateView, SheetDetailView, SheetListView, SheetUpdateView
|
||||
SheetCreateView, SheetDetailView, SheetListView, SheetUpdateView, WaitingListDetailView, WaitingListView
|
||||
|
||||
app_name = 'sheets'
|
||||
|
||||
@ -18,4 +18,9 @@ urlpatterns = [
|
||||
path('meal/create/<int:pk>/', MealCreateView.as_view(), name="meal_create"),
|
||||
path('meal/<int:pk>/update/', MealUpdateView.as_view(), name="meal_update"),
|
||||
path('order/<int:pk>/', OrderView.as_view(), name="sheet_order"),
|
||||
path('waiting-list/<int:pk>/', WaitingListView.as_view(), name="waiting_list"),
|
||||
path('waiting-list/<int:pk>/queued/', WaitingListDetailView.as_view(), name="queued_list"),
|
||||
path('waiting-list/<int:pk>/ready/', WaitingListDetailView.as_view(), name="ready_list"),
|
||||
path('waiting-list/<int:pk>/served/', WaitingListDetailView.as_view(), name="served_list"),
|
||||
path('waiting-list/<int:pk>/canceled/', WaitingListDetailView.as_view(), name="canceled_list"),
|
||||
]
|
||||
|
@ -235,6 +235,7 @@ class OrderView(LoginRequiredMixin, FormView, DetailView):
|
||||
label=_("gift").capitalize(),
|
||||
initial=0,
|
||||
widget=AmountInput(),
|
||||
help_text=_("Be careful: this gift will be multiplied for each order."),
|
||||
)
|
||||
form.fields[f'meal_{meal.id}_remark'] = forms.CharField(
|
||||
max_length=255,
|
||||
@ -280,6 +281,7 @@ class OrderView(LoginRequiredMixin, FormView, DetailView):
|
||||
label=_("gift").capitalize(),
|
||||
initial=0,
|
||||
widget=AmountInput(),
|
||||
help_text=_("Be careful: this gift will be multiplied for each order."),
|
||||
)
|
||||
form.fields[f'food_{food.id}_remark'] = forms.CharField(
|
||||
max_length=255,
|
||||
@ -406,3 +408,37 @@ class OrderView(LoginRequiredMixin, FormView, DetailView):
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy('sheets:sheet_detail', args=(self.kwargs['pk'],))
|
||||
|
||||
|
||||
class WaitingListView(ProtectQuerysetMixin, DetailView):
|
||||
model = Food
|
||||
template_name = 'sheets/waiting_list.html'
|
||||
extra_context = {'title': _("Waiting list")}
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
content = super().get_context_data(**kwargs)
|
||||
|
||||
content['queue'] = OrderedFood.objects.filter(food_id=self.kwargs['pk'], status='QUEUED')\
|
||||
.order_by('-priority', 'number', 'order__date').all()
|
||||
content['ready'] = OrderedFood.objects.filter(food_id=self.kwargs['pk'], status='READY')\
|
||||
.order_by('served_date').all()
|
||||
|
||||
return content
|
||||
|
||||
|
||||
class WaitingListDetailView(ProtectQuerysetMixin, DetailView):
|
||||
model = Food
|
||||
template_name = 'sheets/waiting_list_detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
list_type = 'CANCELED' if 'canceled' in self.request.path else \
|
||||
'SERVED' if 'served' in self.request.path else \
|
||||
'READY' if 'ready' in self.request.path else 'QUEUED'
|
||||
context['list_type'] = list_type
|
||||
context['orders'] = OrderedFood.objects.filter(food_id=self.kwargs['pk'], status=list_type)\
|
||||
.order_by('served_date', '-priority', 'number', 'order__date').all()
|
||||
context['title'] = self.object.name + " - " + _(list_type.lower()).capitalize()
|
||||
|
||||
return context
|
||||
|
Reference in New Issue
Block a user