added ability to link recipes to ingredients

This commit is contained in:
vabene1111
2020-03-17 18:44:11 +01:00
parent a60b09e491
commit 90dbc36402
10 changed files with 94 additions and 6 deletions

View File

@@ -5,8 +5,9 @@ from django.urls import reverse_lazy
from django_tables2 import RequestConfig
from django.utils.translation import gettext as _
from cookbook.models import Keyword, SyncLog, RecipeImport, Storage
from cookbook.tables import KeywordTable, ImportLogTable, RecipeImportTable, StorageTable
from cookbook.filters import IngredientFilter
from cookbook.models import Keyword, SyncLog, RecipeImport, Storage, Ingredient
from cookbook.tables import KeywordTable, ImportLogTable, RecipeImportTable, StorageTable, IngredientTable
@login_required
@@ -34,6 +35,16 @@ def recipe_import(request):
return render(request, 'generic/list_template.html', {'title': _("Import"), 'table': table, 'import_btn': True})
@login_required
def ingredient(request):
f = IngredientFilter(request.GET, queryset=Ingredient.objects.all().order_by('pk'))
table = IngredientTable(f.qs)
RequestConfig(request, paginate={'per_page': 25}).configure(table)
return render(request, 'generic/list_template.html', {'title': _("Ingredients"), 'table': table, 'filter': f})
@login_required
def storage(request):
table = StorageTable(Storage.objects.all())