1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-11-07 23:39:50 +01:00

Add model Recipe

This commit is contained in:
Ehouarn
2025-11-06 23:49:16 +01:00
parent 48b1ef9ec8
commit 0db794c70e
13 changed files with 613 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ from note_kfet.middlewares import get_current_request
from note.templatetags.pretty_money import pretty_money
from permission.backends import PermissionBackend
from .models import Food, Dish, Order
from .models import Food, Dish, Order, Recipe
class FoodTable(tables.Table):
@@ -115,3 +115,21 @@ class OrderTable(tables.Table):
'class': 'table-row',
'style': 'cursor:pointer',
}
class RecipeTable(tables.Table):
"""
List all recipes
"""
def render_ingredients(self, record):
return ", ".join(str(q) for q in record.ingredients)
class Meta:
model = Recipe
template_name = 'django_tables2/bootstrap4.html'
fields = ('name', 'creater', 'ingredients',)
row_attrs = {
'class': 'table-row',
'data-href': lambda record: str(record.pk),
'style': 'cursor:pointer',
}