mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-10-30 23:39:54 +01:00 
			
		
		
		
	Rewrite food apps, new feature some changes to model
This commit is contained in:
		
							
								
								
									
										48
									
								
								apps/food/templates/food/food_detail.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								apps/food/templates/food/food_detail.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| {% extends "base.html" %} | ||||
| {% comment %} | ||||
| Copyright (C) by BDE ENS Paris-Saclay | ||||
| SPDX-License-Identifier: GPL-3.0-or-later | ||||
| {% endcomment %} | ||||
| {% load i18n crispy_forms_tags %} | ||||
|  | ||||
| {% block content %} | ||||
| <div class="card bg-white mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {{ title }} {{ food.name }} | ||||
|   </h3> | ||||
|   <div class="card-body"> | ||||
|     <ul> | ||||
|       {% for field, value in fields %} | ||||
|       <li> {{ field }} : {{ value }}</li> | ||||
|       {% endfor %} | ||||
|       {% if meals %} | ||||
|       <li> {% trans "Contained in" %} :  | ||||
|       {% for meal in meals %} | ||||
|       <a href="{% url "food:transformedfood_view" pk=meal.pk %}">{{ meal.name }}</a>{% if not forloop.last %},{% endif %}  | ||||
|       {% endfor %} | ||||
|       </li> | ||||
|       {% endif %} | ||||
|       {% if foods %} | ||||
|       <li> {% trans "Contain" %} :  | ||||
|       {% for food in foods %} | ||||
|         <a href="{% url "food:food_view" pk=food.pk %}">{{ food.name }}</a>{% if not forloop.last %},{% endif %} | ||||
|       {% endfor %} | ||||
|       </li> | ||||
|       {% endif %} | ||||
|     </ul> | ||||
|       {% if update %} | ||||
| 	<a class="btn btn-sm btn-secondary" href="{% url "food:food_update" pk=food.pk %}"> | ||||
| 	  {% trans "Update" %} | ||||
| 	</a> | ||||
|       {% endif %} | ||||
|       {% if add_ingredient %} | ||||
| 	<a class="btn btn-sm btn-primary" href="{% url "food:add_ingredient" pk=food.pk %}"> | ||||
| 	  {% trans "Add to a meal" %} | ||||
| 	</a> | ||||
|       {% endif %} | ||||
| 	<a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}"> | ||||
| 	  {% trans "Return to the food list" %} | ||||
| 	</a> | ||||
|   </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
							
								
								
									
										71
									
								
								apps/food/templates/food/food_list.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								apps/food/templates/food/food_list.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| {% extends "base_search.html" %} | ||||
| {% comment %} | ||||
| Copyright (C) 2018-2025 by BDE ENS Paris-Saclay | ||||
| SPDX-License-Identifier: GPL-3.0-or-later | ||||
| {% endcomment %} | ||||
| {% load render_table from django_tables2 %} | ||||
| {% load i18n %} | ||||
|  | ||||
| {% block content %} | ||||
| {{ block.super }} | ||||
| <br> | ||||
| <div class="card bg-light mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {% trans "Meal served" %} | ||||
|   </h3> | ||||
|   {% if can_add_meal %} | ||||
|   <div class="card-footer"> | ||||
|     <a class="btn btn-sm btn-primary" href="{% url 'food:transformedfood_create' %}"> | ||||
|       {% trans "New meal" %} | ||||
|     </a> | ||||
|   </div> | ||||
|   {% endif %} | ||||
|   {% if served.data %} | ||||
|   {% render_table served %} | ||||
|   {% else %} | ||||
|   <div class="card-body"> | ||||
|     <div class="alert alert-warning"> | ||||
|       {% trans "There is no meal served." %} | ||||
|     </div> | ||||
|   </div> | ||||
| </div> | ||||
|   {% endif %} | ||||
| <div class="card bg-light mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {% trans "Free food" %} | ||||
|   </h3> | ||||
|   {% if open.data %} | ||||
|   {% render_table open %} | ||||
|   {% else %} | ||||
|   <div class="card-body"> | ||||
|     <div class="alert alert-warning"> | ||||
|       {% trans "There is no free food." %} | ||||
|     </div> | ||||
|   </div> | ||||
|   {% endif %} | ||||
| </div> | ||||
| {% if club_tables %} | ||||
| <div class="card bg-light mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {% trans "Food of your clubs" %} | ||||
|   </h3> | ||||
| </div> | ||||
|   {% for table in club_tables %} | ||||
| <div class="card bg-light mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {% trans "Food of club" %} {{ table.prefix }}  | ||||
|   </h3> | ||||
|   {% if table.data %} | ||||
|     {% render_table table %} | ||||
|   {% else %} | ||||
|   <div class="card-body"> | ||||
|     <div class="alert alert-warning"> | ||||
|       {% trans "Yours club has not food yet." %} | ||||
|     </div> | ||||
|   </div> | ||||
|   {% endif %} | ||||
| </div> | ||||
|   {% endfor %} | ||||
|   {% endif %} | ||||
| </div> | ||||
| {% endblock %} | ||||
							
								
								
									
										21
									
								
								apps/food/templates/food/food_update.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								apps/food/templates/food/food_update.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| {% extends "base.html" %} | ||||
| {% comment %} | ||||
| Copyright (C) by BDE ENS Paris-Saclay | ||||
| SPDX-License-Identifier: GPL-3.0-or-later | ||||
| {% endcomment %} | ||||
| {% load i18n crispy_forms_tags %} | ||||
|  | ||||
| {% block content %} | ||||
| <div class="card bg-white mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {{ title }} | ||||
|   </h3> | ||||
|   <div class="card-body" id="form"> | ||||
|     <form method="post"> | ||||
|       {% csrf_token %} | ||||
|       {{ form | crispy }} | ||||
|       <button class="btn btn-primary" type="submit">{% trans "Submit"%}</button> | ||||
|     </form> | ||||
|   </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
							
								
								
									
										52
									
								
								apps/food/templates/food/qrcode.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								apps/food/templates/food/qrcode.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| {% extends "base.html" %} | ||||
| {% comment %} | ||||
| Copyright (C) by BDE ENS Paris-Saclay | ||||
| SPDX-License-Identifier: GPL-3.0-or-later | ||||
| {% endcomment %} | ||||
| {% load i18n crispy_forms_tags %} | ||||
| {% load render_table from django_tables2 %} | ||||
|  | ||||
| {% block content %} | ||||
| <div class="card bg-white mb-3"> | ||||
|   <h3 class="card-header text-center"> | ||||
|     {{ title }} | ||||
|   </h3> | ||||
|   <div class="card-body" id="form"> | ||||
|     <form method="post"> | ||||
|       {% csrf_token %} | ||||
|       {{ form | crispy }} | ||||
|       <button class="btn btn-primary" type="submit">{% trans "Submit"%}</button> | ||||
|     </form> | ||||
|     <div class="card-body"> | ||||
|     <h4> | ||||
|       {% trans "Copy constructor" %} | ||||
|       <a class="btn btn-secondary" href="{% url "food:basicfood_create" slug=slug %}">{% trans "New food" %}</a> | ||||
|     </h4> | ||||
|       <table class="table"> | ||||
| 	<thead> | ||||
| 	  <tr> | ||||
| 	    <th class="orderable"> | ||||
| 	      {% trans "Name" %} | ||||
| 	    </th> | ||||
| 	    <th class="orderable"> | ||||
| 	      {% trans "Owner" %} | ||||
| 	    </th> | ||||
| 	    <th class="orderable"> | ||||
| 	      {% trans "Expiry date" %} | ||||
| 	    </th> | ||||
| 	  </tr> | ||||
| 	</thead> | ||||
| 	<tbody> | ||||
| 	  {% for food in last_items %} | ||||
| 	    <tr> | ||||
| 		    <td><a href="{% url "food:basicfood_create" slug=slug %}?copy={{ food.pk }}">{{ food.name }}</a></td> | ||||
| 	      <td>{{ food.owner }}</td> | ||||
| 	      <td>{{ food.expiry_date }}</td> | ||||
| 	    </tr> | ||||
| 	  {% endfor %} | ||||
| 	</tbody> | ||||
|       </table> | ||||
|     </div> | ||||
|   </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
		Reference in New Issue
	
	Block a user