mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-19 07:31:24 +02:00
Merge branch 'food_traceability' into 'beta'
Easier access to food details See merge request bde/nk20!326
This commit is contained in:
@ -7,7 +7,52 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ block.super }}
|
<div class="card bg-light">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
<style>
|
||||||
|
input[type=number]::-webkit-inner-spin-button,
|
||||||
|
input[type=number]::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
input[type=number] {
|
||||||
|
appearance: textfield;
|
||||||
|
padding: 6px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="d-flex align-items-center" style="max-width: 300px;">
|
||||||
|
<form method="get" action="{% url 'food:redirect_view' %}" class="d-flex w-100">
|
||||||
|
<input type="number" name="slug" placeholder="QR-code" required class="form-control form-control-sm" style="max-width: 120px;">
|
||||||
|
<button type="submit" class="btn btn-sm btn-primary">{% trans "View food" %}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<input id="searchbar" type="text" class="form-control"
|
||||||
|
placeholder="{% trans "Search by attribute such as name..." %}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% block extra_inside_card %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<div id="dynamic-table">
|
||||||
|
{% if table.data %}
|
||||||
|
{% render_table table %}
|
||||||
|
{% else %}
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
{% trans "There is no results." %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="card bg-light mb-3">
|
<div class="card bg-light mb-3">
|
||||||
<h3 class="card-header text-center">
|
<h3 class="card-header text-center">
|
||||||
@ -68,4 +113,20 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
document.getElementById('goButton').addEventListener('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const slug = document.getElementById('slugInput').value;
|
||||||
|
if (slug && !isNaN(slug)) {
|
||||||
|
window.location.href = `/food/${slug}/`;
|
||||||
|
} else {
|
||||||
|
alert("Veuillez entrer un nombre valide.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -18,4 +18,5 @@ urlpatterns = [
|
|||||||
path('detail/basic/<int:pk>', views.BasicFoodDetailView.as_view(), name='basicfood_view'),
|
path('detail/basic/<int:pk>', views.BasicFoodDetailView.as_view(), name='basicfood_view'),
|
||||||
path('detail/transformed/<int:pk>', views.TransformedFoodDetailView.as_view(), name='transformedfood_view'),
|
path('detail/transformed/<int:pk>', views.TransformedFoodDetailView.as_view(), name='transformedfood_view'),
|
||||||
path('add/ingredient/<int:pk>', views.AddIngredientView.as_view(), name='add_ingredient'),
|
path('add/ingredient/<int:pk>', views.AddIngredientView.as_view(), name='add_ingredient'),
|
||||||
|
path('redirect/', views.QRCodeRedirectView.as_view(), name='redirect_view'),
|
||||||
]
|
]
|
||||||
|
@ -10,6 +10,7 @@ from django.db.models import Q
|
|||||||
from django.http import HttpResponseRedirect, Http404
|
from django.http import HttpResponseRedirect, Http404
|
||||||
from django.views.generic import DetailView, UpdateView, CreateView
|
from django.views.generic import DetailView, UpdateView, CreateView
|
||||||
from django.views.generic.list import ListView
|
from django.views.generic.list import ListView
|
||||||
|
from django.views.generic.base import RedirectView
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@ -507,3 +508,14 @@ class TransformedFoodDetailView(FoodDetailView):
|
|||||||
if Food.objects.filter(pk=kwargs['pk']).count() == 1:
|
if Food.objects.filter(pk=kwargs['pk']).count() == 1:
|
||||||
kwargs['stop_redirect'] = (Food.objects.get(pk=kwargs['pk']).polymorphic_ctype.model == 'transformedfood')
|
kwargs['stop_redirect'] = (Food.objects.get(pk=kwargs['pk']).polymorphic_ctype.model == 'transformedfood')
|
||||||
return super().get(*args, **kwargs)
|
return super().get(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class QRCodeRedirectView(RedirectView):
|
||||||
|
"""
|
||||||
|
Redirects to the QR code creation page from Food List
|
||||||
|
"""
|
||||||
|
def get_redirect_url(self, *args, **kwargs):
|
||||||
|
slug = self.request.GET.get('slug')
|
||||||
|
if slug:
|
||||||
|
return reverse_lazy('food:qrcode_create', kwargs={'slug': slug})
|
||||||
|
return reverse_lazy('food:list')
|
||||||
|
@ -7,7 +7,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2025-07-06 16:04+0200\n"
|
"POT-Creation-Date: 2025-07-11 16:10+0200\n"
|
||||||
"PO-Revision-Date: 2022-04-11 22:05+0200\n"
|
"PO-Revision-Date: 2022-04-11 22:05+0200\n"
|
||||||
"Last-Translator: bleizi <bleizi@crans.org>\n"
|
"Last-Translator: bleizi <bleizi@crans.org>\n"
|
||||||
"Language-Team: French <http://translate.ynerant.fr/projects/nk20/nk20/fr/>\n"
|
"Language-Team: French <http://translate.ynerant.fr/projects/nk20/nk20/fr/>\n"
|
||||||
@ -597,8 +597,8 @@ msgstr "est prêt"
|
|||||||
msgid "order"
|
msgid "order"
|
||||||
msgstr "consigne"
|
msgstr "consigne"
|
||||||
|
|
||||||
#: apps/food/models.py:107 apps/food/views.py:34
|
#: apps/food/models.py:107 apps/food/views.py:35
|
||||||
#: note_kfet/templates/base.html:73
|
#: note_kfet/templates/base.html:72
|
||||||
msgid "Food"
|
msgid "Food"
|
||||||
msgstr "Bouffe"
|
msgstr "Bouffe"
|
||||||
|
|
||||||
@ -659,59 +659,73 @@ msgstr "QR-codes"
|
|||||||
msgid "QR-code number"
|
msgid "QR-code number"
|
||||||
msgstr "Numéro de QR-code"
|
msgstr "Numéro de QR-code"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:19
|
#: apps/food/templates/food/food_detail.html:22
|
||||||
msgid "Contained in"
|
msgid "Contained in"
|
||||||
msgstr "Contenu dans"
|
msgstr "Contenu dans"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:26
|
#: apps/food/templates/food/food_detail.html:29
|
||||||
msgid "Contain"
|
msgid "Contain"
|
||||||
msgstr "Contient"
|
msgstr "Contient"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:35
|
#: apps/food/templates/food/food_detail.html:38
|
||||||
msgid "Update"
|
msgid "Update"
|
||||||
msgstr "Modifier"
|
msgstr "Modifier"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:40
|
#: apps/food/templates/food/food_detail.html:43
|
||||||
msgid "Add to a meal"
|
msgid "Add to a meal"
|
||||||
msgstr "Ajouter à un plat"
|
msgstr "Ajouter à un plat"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:45
|
#: apps/food/templates/food/food_detail.html:48
|
||||||
msgid "Manage ingredients"
|
msgid "Manage ingredients"
|
||||||
msgstr "Gérer les ingrédients"
|
msgstr "Gérer les ingrédients"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_detail.html:49
|
#: apps/food/templates/food/food_detail.html:52
|
||||||
msgid "Return to the food list"
|
msgid "Return to the food list"
|
||||||
msgstr "Retour à la liste de nourriture"
|
msgstr "Retour à la liste de nourriture"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:14
|
#: apps/food/templates/food/food_list.html:32
|
||||||
|
msgid "View food"
|
||||||
|
msgstr "Voir l'aliment"
|
||||||
|
|
||||||
|
#: apps/food/templates/food/food_list.html:37
|
||||||
|
#: note_kfet/templates/base_search.html:15
|
||||||
|
msgid "Search by attribute such as name..."
|
||||||
|
msgstr "Chercher par un attribut tel que le nom..."
|
||||||
|
|
||||||
|
#: apps/food/templates/food/food_list.html:49
|
||||||
|
#: note_kfet/templates/base_search.html:23
|
||||||
|
msgid "There is no results."
|
||||||
|
msgstr "Il n'y a pas de résultat."
|
||||||
|
|
||||||
|
#: apps/food/templates/food/food_list.html:58
|
||||||
msgid "Meal served"
|
msgid "Meal served"
|
||||||
msgstr "Plat servis"
|
msgstr "Plat servis"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:19
|
#: apps/food/templates/food/food_list.html:63
|
||||||
msgid "New meal"
|
msgid "New meal"
|
||||||
msgstr "Nouveau plat"
|
msgstr "Nouveau plat"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:28
|
#: apps/food/templates/food/food_list.html:72
|
||||||
msgid "There is no meal served."
|
msgid "There is no meal served."
|
||||||
msgstr "Il n'y a pas de plat servi."
|
msgstr "Il n'y a pas de plat servi."
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:35
|
#: apps/food/templates/food/food_list.html:79
|
||||||
msgid "Free food"
|
msgid "Free food"
|
||||||
msgstr "Open"
|
msgstr "Open"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:42
|
#: apps/food/templates/food/food_list.html:86
|
||||||
msgid "There is no free food."
|
msgid "There is no free food."
|
||||||
msgstr "Il n'y a pas de bouffe en open"
|
msgstr "Il n'y a pas de bouffe en open"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:50
|
#: apps/food/templates/food/food_list.html:94
|
||||||
msgid "Food of your clubs"
|
msgid "Food of your clubs"
|
||||||
msgstr "Bouffe de tes clubs"
|
msgstr "Bouffe de tes clubs"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:56
|
#: apps/food/templates/food/food_list.html:100
|
||||||
msgid "Food of club"
|
msgid "Food of club"
|
||||||
msgstr "Bouffe du club"
|
msgstr "Bouffe du club"
|
||||||
|
|
||||||
#: apps/food/templates/food/food_list.html:63
|
#: apps/food/templates/food/food_list.html:107
|
||||||
msgid "Yours club has not food yet."
|
msgid "Yours club has not food yet."
|
||||||
msgstr "Ton club n'a pas de bouffe pour l'instant"
|
msgstr "Ton club n'a pas de bouffe pour l'instant"
|
||||||
|
|
||||||
@ -785,49 +799,49 @@ msgstr "semaines"
|
|||||||
msgid "and"
|
msgid "and"
|
||||||
msgstr "et"
|
msgstr "et"
|
||||||
|
|
||||||
#: apps/food/views.py:119
|
#: apps/food/views.py:120
|
||||||
msgid "Add a new QRCode"
|
msgid "Add a new QRCode"
|
||||||
msgstr "Ajouter un nouveau QR-code"
|
msgstr "Ajouter un nouveau QR-code"
|
||||||
|
|
||||||
#: apps/food/views.py:168
|
#: apps/food/views.py:169
|
||||||
msgid "Add an aliment"
|
msgid "Add an aliment"
|
||||||
msgstr "Ajouter un nouvel aliment"
|
msgstr "Ajouter un nouvel aliment"
|
||||||
|
|
||||||
#: apps/food/views.py:236
|
#: apps/food/views.py:228
|
||||||
msgid "Add a meal"
|
msgid "Add a meal"
|
||||||
msgstr "Ajouter un plat"
|
msgstr "Ajouter un plat"
|
||||||
|
|
||||||
#: apps/food/views.py:276
|
#: apps/food/views.py:259
|
||||||
msgid "Manage ingredients of:"
|
msgid "Manage ingredients of:"
|
||||||
msgstr "Gestion des ingrédienrs de :"
|
msgstr "Gestion des ingrédienrs de :"
|
||||||
|
|
||||||
#: apps/food/views.py:290 apps/food/views.py:298
|
#: apps/food/views.py:273 apps/food/views.py:281
|
||||||
#, python-brace-format
|
#, python-brace-format
|
||||||
msgid "Fully used in {meal}"
|
msgid "Fully used in {meal}"
|
||||||
msgstr "Aliment entièrement utilisé dans : {meal}"
|
msgstr "Aliment entièrement utilisé dans : {meal}"
|
||||||
|
|
||||||
#: apps/food/views.py:345
|
#: apps/food/views.py:320
|
||||||
msgid "Add the ingredient:"
|
msgid "Add the ingredient:"
|
||||||
msgstr "Ajouter l'ingrédient"
|
msgstr "Ajouter l'ingrédient"
|
||||||
|
|
||||||
#: apps/food/views.py:371
|
#: apps/food/views.py:346
|
||||||
#, python-brace-format
|
#, python-brace-format
|
||||||
msgid "Food fully used in : {meal.name}"
|
msgid "Food fully used in : {meal.name}"
|
||||||
msgstr "Aliment entièrement utilisé dans : {meal.name}"
|
msgstr "Aliment entièrement utilisé dans : {meal.name}"
|
||||||
|
|
||||||
#: apps/food/views.py:390
|
#: apps/food/views.py:365
|
||||||
msgid "Update an aliment"
|
msgid "Update an aliment"
|
||||||
msgstr "Modifier un aliment"
|
msgstr "Modifier un aliment"
|
||||||
|
|
||||||
#: apps/food/views.py:438
|
#: apps/food/views.py:413
|
||||||
msgid "Details of:"
|
msgid "Details of:"
|
||||||
msgstr "Détails de :"
|
msgstr "Détails de :"
|
||||||
|
|
||||||
#: apps/food/views.py:448 apps/treasury/tables.py:149
|
#: apps/food/views.py:423 apps/treasury/tables.py:149
|
||||||
msgid "Yes"
|
msgid "Yes"
|
||||||
msgstr "Oui"
|
msgstr "Oui"
|
||||||
|
|
||||||
#: apps/food/views.py:450 apps/member/models.py:99 apps/treasury/tables.py:149
|
#: apps/food/views.py:425 apps/member/models.py:99 apps/treasury/tables.py:149
|
||||||
msgid "No"
|
msgid "No"
|
||||||
msgstr "Non"
|
msgstr "Non"
|
||||||
|
|
||||||
@ -4341,10 +4355,86 @@ msgstr ""
|
|||||||
"d'adhésion. Vous devez également valider votre adresse email en suivant le "
|
"d'adhésion. Vous devez également valider votre adresse email en suivant le "
|
||||||
"lien que vous avez reçu."
|
"lien que vous avez reçu."
|
||||||
|
|
||||||
#, fuzzy, python-format
|
#, fuzzy
|
||||||
#~| msgid "Creation date"
|
#~| msgid "QR-code"
|
||||||
#~ msgid "Deposit %(name)s"
|
#~ msgid "Go to QR-code"
|
||||||
#~ msgstr "Caution %(name)s"
|
#~ msgstr "QR-code"
|
||||||
|
|
||||||
|
#, python-brace-format
|
||||||
|
#~ msgid "QR-code number {qr_code_number}"
|
||||||
|
#~ msgstr "Numéro du QR-code {qr_code_number}"
|
||||||
|
|
||||||
|
#~ msgid "was eaten"
|
||||||
|
#~ msgstr "a été mangé"
|
||||||
|
|
||||||
|
#~ msgid "is active"
|
||||||
|
#~ msgstr "est en cours"
|
||||||
|
|
||||||
|
#~ msgid "foods"
|
||||||
|
#~ msgstr "bouffes"
|
||||||
|
|
||||||
|
#~ msgid "Arrival date"
|
||||||
|
#~ msgstr "Date d'arrivée"
|
||||||
|
|
||||||
|
#~ msgid "Active"
|
||||||
|
#~ msgstr "Actif"
|
||||||
|
|
||||||
|
#~ msgid "Eaten"
|
||||||
|
#~ msgstr "Mangé"
|
||||||
|
|
||||||
|
#~ msgid "number"
|
||||||
|
#~ msgstr "numéro"
|
||||||
|
|
||||||
|
#~ msgid "View details"
|
||||||
|
#~ msgstr "Voir plus"
|
||||||
|
|
||||||
|
#~ msgid "Ready"
|
||||||
|
#~ msgstr "Prêt"
|
||||||
|
|
||||||
|
#~ msgid "Creation date"
|
||||||
|
#~ msgstr "Date de création"
|
||||||
|
|
||||||
|
#~ msgid "Ingredients"
|
||||||
|
#~ msgstr "Ingrédients"
|
||||||
|
|
||||||
|
#~ msgid "Open"
|
||||||
|
#~ msgstr "Open"
|
||||||
|
|
||||||
|
#~ msgid "All meals"
|
||||||
|
#~ msgstr "Tout les plats"
|
||||||
|
|
||||||
|
#~ msgid "There is no meal."
|
||||||
|
#~ msgstr "Il n'y a pas de plat"
|
||||||
|
|
||||||
|
#~ msgid "The product is already prepared"
|
||||||
|
#~ msgstr "Le produit est déjà prêt"
|
||||||
|
|
||||||
|
#~ msgid "Add a new basic food with QRCode"
|
||||||
|
#~ msgstr "Ajouter un nouvel ingrédient avec un QR-code"
|
||||||
|
|
||||||
|
#~ msgid "QRCode"
|
||||||
|
#~ msgstr "QR-code"
|
||||||
|
|
||||||
|
#~ msgid "Add a new meal"
|
||||||
|
#~ msgstr "Ajouter un nouveau plat"
|
||||||
|
|
||||||
|
#~ msgid "Update a meal"
|
||||||
|
#~ msgstr "Modifier le plat"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
#~| msgid "invalidate"
|
||||||
|
#~ msgid "Enter a valid color."
|
||||||
|
#~ msgstr "dévalider"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
#~| msgid "invalidate"
|
||||||
|
#~ msgid "Enter a valid value."
|
||||||
|
#~ msgstr "dévalider"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
#~| msgid "Invitation"
|
||||||
|
#~ msgid "Syndication"
|
||||||
|
#~ msgstr "Invitation"
|
||||||
|
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
#~| msgid "There is no results."
|
#~| msgid "There is no results."
|
||||||
|
Reference in New Issue
Block a user