From 7518d8c6b1bfbe14f36a2695a1a6caae702c4ccb Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 17 Mar 2020 17:36:05 +0100 Subject: [PATCH] fixed several rewrite issues --- cookbook/tables.py | 2 +- cookbook/urls.py | 9 +++++---- cookbook/views/api.py | 4 ++-- cookbook/views/data.py | 2 +- cookbook/views/delete.py | 6 +++--- cookbook/views/edit.py | 8 ++++---- cookbook/views/new.py | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cookbook/tables.py b/cookbook/tables.py index aaed0c50..85fdc3a9 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -71,7 +71,7 @@ class SyncTable(tables.Table): class RecipeImportTable(tables.Table): id = tables.LinkColumn('new_recipe_import', args=[A('id')]) - delete = tables.TemplateColumn("" + _('Delete') + "") + delete = tables.TemplateColumn("" + _('Delete') + "") class Meta: model = RecipeImport diff --git a/cookbook/urls.py b/cookbook/urls.py index 8b9ff4d1..dcb35978 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -15,10 +15,11 @@ urlpatterns = [ path('view/recipe/', views.recipe_view, name='view_recipe'), - path('edit/recipe/internal//', edit.internal_recipe_update, name='edit_internal_recipe'), - # for internal use only - path('edit/recipe/external//', edit.RecipeUpdate.as_view(), name='edit_external_recipe'), - # for internal use only + path('new/recipe_import//', new.create_new_external_recipe, name='new_recipe_import'), + + path('edit/recipe//', edit.switch_recipe, name='edit_recipe'), + path('edit/recipe/internal//', edit.internal_recipe_update, name='edit_internal_recipe'), # for internal use only + path('edit/recipe/external//', edit.ExternalRecipeUpdate.as_view(), name='edit_external_recipe'), # for internal use only path('edit/recipe/convert//', edit.convert_recipe, name='edit_convert_recipe'), # for internal use only path('edit/storage//', edit.edit_storage, name='edit_storage'), diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 1e8a728e..5b878437 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -61,7 +61,7 @@ def sync_all(request): if not error: messages.add_message(request, messages.SUCCESS, _('Sync successful!')) - return redirect('list_import') + return redirect('list_recipe_import') else: messages.add_message(request, messages.ERROR, _('Error synchronizing with Storage')) - return redirect('list_import') + return redirect('list_recipe_import') diff --git a/cookbook/views/data.py b/cookbook/views/data.py index 91596c8b..d75bf36b 100644 --- a/cookbook/views/data.py +++ b/cookbook/views/data.py @@ -44,7 +44,7 @@ def batch_import(request): recipe.save() new_recipe.delete() - return redirect('list_import') + return redirect('list_recipe_import') @login_required diff --git a/cookbook/views/delete.py b/cookbook/views/delete.py index 288be2f6..fe595fe2 100644 --- a/cookbook/views/delete.py +++ b/cookbook/views/delete.py @@ -40,13 +40,13 @@ class RecipeSourceDelete(LoginRequiredMixin, DeleteView): return context -class ImportDelete(LoginRequiredMixin, DeleteView): +class RecipeImportDelete(LoginRequiredMixin, DeleteView): template_name = "generic/delete_template.html" model = RecipeImport - success_url = reverse_lazy('list_import') + success_url = reverse_lazy('list_recipe_import') def get_context_data(self, **kwargs): - context = super(ImportDelete, self).get_context_data(**kwargs) + context = super(RecipeImportDelete, self).get_context_data(**kwargs) context['title'] = _("Import") return context diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index cfb91541..780acdbd 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -267,7 +267,7 @@ class MealPlanUpdate(LoginRequiredMixin, UpdateView): return context -class RecipeUpdate(LoginRequiredMixin, UpdateView): +class ExternalRecipeUpdate(LoginRequiredMixin, UpdateView): model = Recipe form_class = ExternalRecipeForm template_name = "generic/edit_template.html" @@ -286,17 +286,17 @@ class RecipeUpdate(LoginRequiredMixin, UpdateView): os.path.splitext(self.object.file_path)[1] messages.add_message(self.request, messages.SUCCESS, _('Changes saved!')) - return super(RecipeUpdate, self).form_valid(form) + return super(ExternalRecipeUpdate, self).form_valid(form) def form_invalid(self, form): messages.add_message(self.request, messages.ERROR, _('Error saving changes!')) - return super(RecipeUpdate, self).form_valid(form) + return super(ExternalRecipeUpdate, self).form_valid(form) def get_success_url(self): return reverse('edit_recipe', kwargs={'pk': self.object.pk}) def get_context_data(self, **kwargs): - context = super(RecipeUpdate, self).get_context_data(**kwargs) + context = super(ExternalRecipeUpdate, self).get_context_data(**kwargs) context['title'] = _("Recipe") context['view_url'] = reverse('view_recipe', args=[self.object.pk]) if self.object.storage: diff --git a/cookbook/views/new.py b/cookbook/views/new.py index a6a798bd..b413ac28 100644 --- a/cookbook/views/new.py +++ b/cookbook/views/new.py @@ -84,7 +84,7 @@ def create_new_external_recipe(request, import_id): RecipeImport.objects.get(id=import_id).delete() messages.add_message(request, messages.SUCCESS, _('Imported new recipe!')) - return redirect('list_import') + return redirect('list_recipe_import') else: messages.add_message(request, messages.ERROR, _('There was an error importing this recipe!')) else: