This commit is contained in:
vabene1111 2019-11-13 23:41:54 +01:00
parent 50cd44d13b
commit c688253144
2 changed files with 15 additions and 2 deletions

View File

@ -18,7 +18,10 @@ urlpatterns = [
path('list/import', lists.recipe_import, name='list_import'),
path('list/storage', lists.storage, name='list_storage'),
path('edit/recipe/<int:pk>/', edit.RecipeUpdate.as_view(), name='edit_recipe'),
path('edit/recipe/<int:pk>/', edit.switch_recipe, name='edit_recipe'),
path('edit/recipe/internal/<int:pk>/', edit.internal_recipe_update, name='edit_internal_recipe'), # for internal use only
path('edit/recipe/external/<int:pk>/', edit.RecipeUpdate.as_view(), name='edit_external_recipe'), # for internal use only
path('edit/keyword/<int:pk>/', edit.KeywordUpdate.as_view(), name='edit_keyword'),
path('edit/sync/<int:pk>/', edit.SyncUpdate.as_view(), name='edit_sync'),
path('edit/import/<int:pk>/', edit.ImportUpdate.as_view(), name='edit_import'),

View File

@ -1,6 +1,7 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from django.shortcuts import redirect, get_object_or_404, render
from django.urls import reverse_lazy, reverse
from django.utils.translation import gettext as _
@ -11,7 +12,16 @@ from cookbook.models import Recipe, Sync, Keyword, RecipeImport, Storage
@login_required
def edit_internal_recipe(request, pk):
def switch_recipe(request, pk):
recipe = get_object_or_404(Recipe, pk=pk)
if recipe.instructions:
return HttpResponseRedirect(reverse('edit_internal_recipe', args=[pk]))
else:
return HttpResponseRedirect(reverse('edit_external_recipe', args=[pk]))
@login_required
def internal_recipe_update(request, pk):
recipe_instance = get_object_or_404(Recipe, pk=pk)
if request.method == "POST":