added ability to open ingredient editor from food/unit list

This commit is contained in:
vabene1111
2022-04-17 22:43:33 +02:00
parent d50fb69ce9
commit f0d59a8c9c
7 changed files with 53 additions and 5 deletions

View File

@ -228,7 +228,15 @@ def supermarket(request):
@group_required('user')
def ingredient_editor(request):
return render(request, 'ingredient_editor.html', {})
template_vars = {'food_id': -1, 'unit_id': -1}
food_id = request.GET.get('food_id', None)
if food_id and re.match(r'^(\d)+$', food_id):
template_vars['food_id'] = food_id
unit_id = request.GET.get('unit_id', None)
if unit_id and re.match(r'^(\d)+$', unit_id):
template_vars['unit_id'] = unit_id
return render(request, 'ingredient_editor.html', template_vars)
@group_required('user')