shopping list basics

This commit is contained in:
vabene1111
2020-08-11 12:17:12 +02:00
parent 82497c734a
commit 8055754455
7 changed files with 95 additions and 53 deletions

View File

@ -6,8 +6,8 @@ from django_tables2 import RequestConfig
from cookbook.filters import IngredientFilter
from cookbook.helper.permission_helper import group_required
from cookbook.models import Keyword, SyncLog, RecipeImport, Storage, Food
from cookbook.tables import KeywordTable, ImportLogTable, RecipeImportTable, StorageTable, IngredientTable
from cookbook.models import Keyword, SyncLog, RecipeImport, Storage, Food, ShoppingList
from cookbook.tables import KeywordTable, ImportLogTable, RecipeImportTable, StorageTable, IngredientTable, ShoppingListTable
@group_required('user')
@ -45,6 +45,14 @@ def food(request):
return render(request, 'generic/list_template.html', {'title': _("Ingredients"), 'table': table, 'filter': f})
@group_required('user')
def shopping_list(request):
table = ShoppingListTable(ShoppingList.objects.filter(created_by=request.user).all())
RequestConfig(request, paginate={'per_page': 25}).configure(table)
return render(request, 'generic/list_template.html', {'title': _("Shopping Lists"), 'table': table, 'create_url': 'new_storage'})
@group_required('admin')
def storage(request):
table = StorageTable(Storage.objects.all())