From 51d60d064c3abab0d61a0b7346b5b86440a9a284 Mon Sep 17 00:00:00 2001 From: Emmy D'ANELLO Date: Thu, 18 Aug 2022 23:44:49 +0200 Subject: [PATCH] Add waiting lists interfaces Signed-off-by: Emmy D'ANELLO --- apps/note/templates/sheets/waiting_list.html | 88 +++++++++ .../templates/sheets/waiting_list_detail.html | 152 ++++++++++++++++ .../sheets/templates/sheets/sheet_detail.html | 4 + apps/sheets/urls.py | 7 +- apps/sheets/views.py | 36 ++++ locale/fr/LC_MESSAGES/django.po | 170 ++++++++++++------ 6 files changed, 406 insertions(+), 51 deletions(-) create mode 100644 apps/note/templates/sheets/waiting_list.html create mode 100644 apps/note/templates/sheets/waiting_list_detail.html diff --git a/apps/note/templates/sheets/waiting_list.html b/apps/note/templates/sheets/waiting_list.html new file mode 100644 index 00000000..e0883c0e --- /dev/null +++ b/apps/note/templates/sheets/waiting_list.html @@ -0,0 +1,88 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block content %} +
+
+

{{ food.name }}

+
+
+
+
+
+

{% trans "queued"|capfirst %}{% if queue %} ({{ queue|length }}){% endif %}

+
+
+
    + {% for ordered_food in queue %} +
  • + {{ ordered_food.order.note }} + {% if ordered_food.priority %} + {{ ordered_food.priority }} + {% endif %} +
  • + {% empty %} +
    + {% trans "There is no queued order." %} +
    + {% endfor %} +
+
+
+
+
+

{% trans "ready"|capfirst %}

+
+
+
    + {% for ordered_food in ready %} +
  • {{ ordered_food.order.note }}
  • + {% empty %} +
    + {% trans "There is no ready order." %} +
    + {% endfor %} +
+
+
+
+ +
+ +

{% trans "Other waiting lists:" %}

+
    + {% for other_food in food.sheet.food_set.all %} + {% if other_food != food %} +
  • + {{ other_food }} +
  • + {% endif %} + {% endfor %} +
+
+ +
+{% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/apps/note/templates/sheets/waiting_list_detail.html b/apps/note/templates/sheets/waiting_list_detail.html new file mode 100644 index 00000000..2e80239d --- /dev/null +++ b/apps/note/templates/sheets/waiting_list_detail.html @@ -0,0 +1,152 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block content %} +
+
+

{{ title }}

+
+
+ {% for of in orders %} +
+
+

{{ of.order.note }}

+
+
+
+
{% trans 'date'|capfirst %}
+
{{ of.order.date }}
+ + {% if of.number > 1 %} +
{% trans 'order number'|capfirst %}
+
{{ of.number }}
+ {% endif %} + + {% if of.priority %} +
{% trans 'priority request'|capfirst %}
+
{{ of.priority }}
+ {% endif %} + + {% if of.remark %} +
{% trans 'remark'|capfirst %}
+
{{ of.remark }}
+ {% endif %} + + {% if of.options.count %} +
{% trans 'options'|capfirst %}
+
{{ of.options.all|join:', ' }}
+ {% endif %} +
+
+ +
+ {% empty %} +
+ {% trans "There is no queued order." %} +
+ {% endfor %} +
+
+ +
+
+

{% trans "Other waiting lists:" %}

+
    + {% for other_food in food.sheet.food_set.all %} + {% if other_food != food %} +
  • + {% if list_type == 'QUEUED' %} + {{ other_food }} + {% else %} + {{ other_food }} + {% endif %} +
  • + {% endif %} + {% endfor %} +
+
+ +
+{% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/apps/sheets/templates/sheets/sheet_detail.html b/apps/sheets/templates/sheets/sheet_detail.html index 04679958..f33d0c71 100644 --- a/apps/sheets/templates/sheets/sheet_detail.html +++ b/apps/sheets/templates/sheets/sheet_detail.html @@ -42,6 +42,10 @@ {% for food in sheet.food_set.all %} {{ food }} ({{ food.price|pretty_money }}) + + + {% trans "Waiting list" %} + {% if can_change_sheet %} diff --git a/apps/sheets/urls.py b/apps/sheets/urls.py index 0449f93d..e7889ad2 100644 --- a/apps/sheets/urls.py +++ b/apps/sheets/urls.py @@ -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//', MealCreateView.as_view(), name="meal_create"), path('meal//update/', MealUpdateView.as_view(), name="meal_update"), path('order//', OrderView.as_view(), name="sheet_order"), + path('waiting-list//', WaitingListView.as_view(), name="waiting_list"), + path('waiting-list//queued/', WaitingListDetailView.as_view(), name="queued_list"), + path('waiting-list//ready/', WaitingListDetailView.as_view(), name="ready_list"), + path('waiting-list//served/', WaitingListDetailView.as_view(), name="served_list"), + path('waiting-list//canceled/', WaitingListDetailView.as_view(), name="canceled_list"), ] diff --git a/apps/sheets/views.py b/apps/sheets/views.py index d7a461f3..d91b4d44 100644 --- a/apps/sheets/views.py +++ b/apps/sheets/views.py @@ -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 diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 0fbaf922..d58f83be 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-18 17:20+0200\n" +"POT-Creation-Date: 2022-08-18 22:51+0200\n" "PO-Revision-Date: 2022-04-11 22:05+0200\n" "Last-Translator: elkmaennchen \n" "Language-Team: French \n" @@ -1476,7 +1476,7 @@ msgstr "modèles de transaction" msgid "used alias" msgstr "alias utilisé" -#: apps/note/models/transactions.py:136 apps/sheets/views.py:276 +#: apps/note/models/transactions.py:136 apps/sheets/views.py:277 msgid "quantity" msgstr "quantité" @@ -1600,7 +1600,7 @@ msgstr "Supprimer" #: apps/note/tables.py:222 apps/note/templates/note/conso_form.html:132 #: apps/sheets/templates/sheets/sheet_detail.html:21 #: apps/sheets/templates/sheets/sheet_detail.html:36 -#: apps/sheets/templates/sheets/sheet_detail.html:48 apps/wei/tables.py:49 +#: apps/sheets/templates/sheets/sheet_detail.html:52 apps/wei/tables.py:49 #: apps/wei/tables.py:50 apps/wei/templates/wei/base.html:89 #: apps/wei/templates/wei/bus_detail.html:20 #: apps/wei/templates/wei/busteam_detail.html:20 @@ -1754,6 +1754,98 @@ msgstr "Bouton affiché" msgid "An error occured" msgstr "Une erreur s'est produite" +#: apps/note/templates/sheets/waiting_list.html:14 apps/sheets/models.py:244 +msgid "queued" +msgstr "en attente" + +#: apps/note/templates/sheets/waiting_list.html:27 +#: apps/note/templates/sheets/waiting_list_detail.html:67 +msgid "There is no queued order." +msgstr "Il n'y a pas de commande en attente." + +#: apps/note/templates/sheets/waiting_list.html:35 apps/sheets/models.py:245 +msgid "ready" +msgstr "prêt" + +#: apps/note/templates/sheets/waiting_list.html:43 +msgid "There is no ready order." +msgstr "Il n'y a pas de commande prête." + +#: apps/note/templates/sheets/waiting_list.html:53 +#: apps/note/templates/sheets/waiting_list_detail.html:75 +msgid "Other waiting lists:" +msgstr "Autres listes d'attente :" + +#: apps/note/templates/sheets/waiting_list.html:66 +#: apps/note/templates/sheets/waiting_list_detail.html:93 +msgid "Queued orders" +msgstr "Commandes en attente" + +#: apps/note/templates/sheets/waiting_list.html:69 +#: apps/note/templates/sheets/waiting_list_detail.html:98 +msgid "Ready orders" +msgstr "Commandes prêtes" + +#: apps/note/templates/sheets/waiting_list.html:72 +#: apps/note/templates/sheets/waiting_list_detail.html:115 +msgid "Back to note sheet detail" +msgstr "Retour aux détails de la feuille de note" + +#: apps/note/templates/sheets/waiting_list_detail.html:18 +#: apps/sheets/models.py:161 +msgid "date" +msgstr "date" + +#: apps/note/templates/sheets/waiting_list_detail.html:22 +msgid "order number" +msgstr "nombre de commandes" + +#: apps/note/templates/sheets/waiting_list_detail.html:27 +#: apps/sheets/models.py:229 apps/sheets/views.py:249 apps/sheets/views.py:295 +msgid "priority request" +msgstr "demande de priorité" + +#: apps/note/templates/sheets/waiting_list_detail.html:32 +#: apps/sheets/models.py:222 apps/sheets/views.py:243 apps/sheets/views.py:289 +msgid "remark" +msgstr "remarques" + +#: apps/note/templates/sheets/waiting_list_detail.html:37 +#: apps/sheets/models.py:216 +msgid "options" +msgstr "options" + +#: apps/note/templates/sheets/waiting_list_detail.html:45 +msgid "Mark as ready" +msgstr "Marquer comme prêt" + +#: apps/note/templates/sheets/waiting_list_detail.html:50 +msgid "Mark as served" +msgstr "Marquer comme servi" + +#: apps/note/templates/sheets/waiting_list_detail.html:55 +msgid "Re-queue" +msgstr "Remettre en attente" + +#: apps/note/templates/sheets/waiting_list_detail.html:60 +#: note_kfet/templates/oauth2_provider/application_confirm_delete.html:17 +#: note_kfet/templates/oauth2_provider/authorize.html:28 +msgid "Cancel" +msgstr "Annuler" + +#: apps/note/templates/sheets/waiting_list_detail.html:103 +msgid "Served orders" +msgstr "Commandes servies" + +#: apps/note/templates/sheets/waiting_list_detail.html:108 +msgid "Canceled orders" +msgstr "Commandes annulées" + +#: apps/note/templates/sheets/waiting_list_detail.html:112 +#: apps/sheets/templates/sheets/sheet_detail.html:47 apps/sheets/views.py:416 +msgid "Waiting list" +msgstr "Liste d'attente" + #: apps/note/views.py:36 msgid "Transfer money" msgstr "Transférer de l'argent" @@ -2240,10 +2332,6 @@ msgstr "menu" msgid "meals" msgstr "menus" -#: apps/sheets/models.py:161 -msgid "date" -msgstr "date" - #: apps/sheets/models.py:166 apps/sheets/models.py:174 #: apps/sheets/models.py:196 msgid "order" @@ -2254,7 +2342,7 @@ msgid "orders" msgstr "commandes" #: apps/sheets/models.py:184 apps/sheets/models.py:233 apps/sheets/views.py:235 -#: apps/sheets/views.py:280 +#: apps/sheets/views.py:281 msgid "gift" msgstr "don" @@ -2266,18 +2354,6 @@ msgstr "menu commandé" msgid "ordered meals" msgstr "menus commandés" -#: apps/sheets/models.py:216 -msgid "options" -msgstr "options" - -#: apps/sheets/models.py:222 apps/sheets/views.py:242 apps/sheets/views.py:287 -msgid "remark" -msgstr "remarques" - -#: apps/sheets/models.py:229 apps/sheets/views.py:248 apps/sheets/views.py:293 -msgid "priority request" -msgstr "demande de priorité" - #: apps/sheets/models.py:237 msgid "number" msgstr "numéro" @@ -2286,14 +2362,6 @@ msgstr "numéro" msgid "How many times the user ordered this." msgstr "Combien de fois cet⋅te utilisateur⋅rice a commandé ceci." -#: apps/sheets/models.py:244 -msgid "queued" -msgstr "en attente" - -#: apps/sheets/models.py:245 -msgid "ready" -msgstr "prêt" - #: apps/sheets/models.py:246 msgid "served" msgstr "servi" @@ -2333,24 +2401,24 @@ msgstr "menu" #: apps/sheets/templates/sheets/sheet_detail.html:31 #: apps/sheets/templates/sheets/sheet_detail.html:43 -#: apps/sheets/templates/sheets/sheet_detail.html:54 +#: apps/sheets/templates/sheets/sheet_detail.html:58 msgid "This product is unavailable." msgstr "Ce produit est indisponible." -#: apps/sheets/templates/sheets/sheet_detail.html:63 +#: apps/sheets/templates/sheets/sheet_detail.html:67 msgid "The menu is empty for now." msgstr "Le menu est vide pour le moment." -#: apps/sheets/templates/sheets/sheet_detail.html:70 +#: apps/sheets/templates/sheets/sheet_detail.html:74 msgid "Add new food" msgstr "Ajouter un plat" -#: apps/sheets/templates/sheets/sheet_detail.html:73 +#: apps/sheets/templates/sheets/sheet_detail.html:77 msgid "Add new meal" msgstr "Ajouter un menu" -#: apps/sheets/templates/sheets/sheet_detail.html:79 apps/sheets/views.py:206 -#: apps/sheets/views.py:317 +#: apps/sheets/templates/sheets/sheet_detail.html:83 apps/sheets/views.py:206 +#: apps/sheets/views.py:319 msgid "Order now" msgstr "Commander maintenant" @@ -2391,41 +2459,45 @@ msgid "Update meal" msgstr "Modifier un menu" #: apps/sheets/views.py:217 -#, fuzzy -#| msgid "order" msgid "Orderer" -msgstr "commande" +msgstr "Commanditaire" #: apps/sheets/views.py:223 -#, fuzzy -#| msgid "orders" msgid "Who orders" -msgstr "commandes" +msgstr "Qui commande" #: apps/sheets/views.py:231 apps/treasury/models.py:140 msgid "Quantity" msgstr "Quantité" -#: apps/sheets/views.py:243 apps/sheets/views.py:288 +#: apps/sheets/views.py:238 apps/sheets/views.py:284 +msgid "Be careful: this gift will be multiplied for each order." +msgstr "Attention : ce don sera multiplié pour chaque commande." + +#: apps/sheets/views.py:244 apps/sheets/views.py:290 msgid "Allergies,…" msgstr "Allergies,…" -#: apps/sheets/views.py:249 apps/sheets/views.py:294 +#: apps/sheets/views.py:250 apps/sheets/views.py:296 msgid "Lesson at 13h30,…" msgstr "Cours à 13h30,…" -#: apps/sheets/views.py:260 +#: apps/sheets/views.py:261 msgid "Options for " msgstr "Options pour " -#: apps/sheets/views.py:304 +#: apps/sheets/views.py:306 msgid "Options" msgstr "Options" -#: apps/sheets/views.py:401 +#: apps/sheets/views.py:403 msgid "You didn't select anything." msgstr "Vous n'avez rien sélectionné." +#: apps/sheets/views.py:432 +msgid "Detailed waiting list" +msgstr "Liste d'attente détaillée" + #: apps/treasury/apps.py:12 note_kfet/templates/base.html:96 msgid "Treasury" msgstr "Trésorerie" @@ -3602,11 +3674,6 @@ msgstr "Il n'y a pas de résultat." msgid "Are you sure to delete the application" msgstr "Êtes-vous sûr⋅e de vouloir supprimer l'application" -#: note_kfet/templates/oauth2_provider/application_confirm_delete.html:17 -#: note_kfet/templates/oauth2_provider/authorize.html:28 -msgid "Cancel" -msgstr "Annuler" - #: note_kfet/templates/oauth2_provider/application_detail.html:11 msgid "Client id" msgstr "ID client" @@ -3817,3 +3884,6 @@ msgstr "" "vous connecter. Vous devez vous rendre à la Kfet et payer les frais " "d'adhésion. Vous devez également valider votre adresse email en suivant le " "lien que vous avez reçu." + +#~ msgid "Detailed view" +#~ msgstr "Vue détaillée"