fixed several rewrite issues

This commit is contained in:
vabene1111 2020-03-17 17:36:05 +01:00
parent eb25a9163f
commit 7518d8c6b1
7 changed files with 17 additions and 16 deletions

View File

@ -71,7 +71,7 @@ class SyncTable(tables.Table):
class RecipeImportTable(tables.Table):
id = tables.LinkColumn('new_recipe_import', args=[A('id')])
delete = tables.TemplateColumn("<a href='{% url 'delete_import' record.id %}' >" + _('Delete') + "</a>")
delete = tables.TemplateColumn("<a href='{% url 'delete_recipe_import' record.id %}' >" + _('Delete') + "</a>")
class Meta:
model = RecipeImport

View File

@ -15,10 +15,11 @@ urlpatterns = [
path('view/recipe/<int:pk>', views.recipe_view, name='view_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('new/recipe_import/<int:import_id>/', new.create_new_external_recipe, name='new_recipe_import'),
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.ExternalRecipeUpdate.as_view(), name='edit_external_recipe'), # for internal use only
path('edit/recipe/convert/<int:pk>/', edit.convert_recipe, name='edit_convert_recipe'), # for internal use only
path('edit/storage/<int:pk>/', edit.edit_storage, name='edit_storage'),

View File

@ -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')

View File

@ -44,7 +44,7 @@ def batch_import(request):
recipe.save()
new_recipe.delete()
return redirect('list_import')
return redirect('list_recipe_import')
@login_required

View File

@ -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

View File

@ -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:

View File

@ -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: