diff --git a/cookbook/tables.py b/cookbook/tables.py index 9dface13..bc1979b4 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -14,8 +14,6 @@ class RecipeTable(tables.Table): attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) all_tags = tables.Column( attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) - delete = tables.TemplateColumn( - "" + _('Delete') + "") # TODO remove and put into edit page class Meta: model = Recipe @@ -25,7 +23,6 @@ class RecipeTable(tables.Table): class CategoryTable(tables.Table): id = tables.LinkColumn('edit_category', args=[A('id')]) - delete = tables.TemplateColumn("" + _('Delete') + "") class Meta: model = Category @@ -35,7 +32,6 @@ class CategoryTable(tables.Table): class KeywordTable(tables.Table): id = tables.LinkColumn('edit_keyword', args=[A('id')]) - delete = tables.TemplateColumn("" + _('Delete') + "") class Meta: model = Keyword @@ -61,7 +57,6 @@ class ImportLogTable(tables.Table): class MonitoredPathTable(tables.Table): id = tables.LinkColumn('edit_monitor', args=[A('id')]) - delete = tables.TemplateColumn("" + _('Delete') + "") @staticmethod def render_path(value): diff --git a/cookbook/templates/generic/edit_template.html b/cookbook/templates/generic/edit_template.html index 79115abe..5b6fc96f 100644 --- a/cookbook/templates/generic/edit_template.html +++ b/cookbook/templates/generic/edit_template.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load crispy_forms_tags %} {% load i18n %} +{% load class_tag %} {% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %} @@ -16,6 +17,7 @@ {% csrf_token %} {{ form|crispy }} + {% trans 'Delete' %} {% endblock %} \ No newline at end of file diff --git a/cookbook/templates/index.html b/cookbook/templates/index.html index e5380e99..3a589096 100644 --- a/cookbook/templates/index.html +++ b/cookbook/templates/index.html @@ -16,15 +16,18 @@ {% if filter %}
- {% trans "Search" %} + {% trans "Search" %} +
-
-
- {{ filter.form|crispy }} - - {% trans 'Reset' %} -
+
{% endif %} diff --git a/cookbook/urls.py b/cookbook/urls.py index b530751b..fff869be 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -24,6 +24,8 @@ urlpatterns = [ path('edit/monitor//', edit.MonitorUpdate.as_view(), name='edit_monitor'), path('edit/import//', edit.ImportUpdate.as_view(), name='edit_import'), + path('redirect/delete///', edit.delete_redirect, name='redirect_delete'), + path('delete/recipe//', edit.RecipeDelete.as_view(), name='delete_recipe'), path('delete/keyword//', edit.KeywordDelete.as_view(), name='delete_keyword'), path('delete/category//', edit.CategoryDelete.as_view(), name='delete_category'), diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index 0026f5e4..6859eb51 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -1,5 +1,6 @@ from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin +from django.shortcuts import redirect from django.urls import reverse_lazy, reverse from django.utils.translation import gettext as _ from django.views.generic import UpdateView, DeleteView @@ -95,6 +96,11 @@ class RecipeUpdate(LoginRequiredMixin, UpdateView): # Generic Delete views + +def delete_redirect(request, name, pk): + return redirect(('delete_' + name), pk) + + class RecipeDelete(LoginRequiredMixin, DeleteView): template_name = "generic\delete_template.html" model = Recipe