mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 21:37:49 -05:00
added ability to open ingredient editor from food/unit list
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
{% endif %}
|
||||
|
||||
<script type="application/javascript">
|
||||
window.DEFAULT_FOOD = {{ food_id }}
|
||||
window.DEFAULT_UNIT = {{ unit_id }}
|
||||
window.CUSTOM_LOCALE = '{{ request.LANGUAGE_CODE }}'
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user