removed delete colums in favor of btn in edit view
This commit is contained in:
parent
7bc102f8df
commit
c5986c6e7f
@ -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(
|
||||
"<a href='{% url 'delete_recipe' record.id %}' >" + _('Delete') + "</a>") # 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("<a href='{% url 'delete_category' record.id %}' >" + _('Delete') + "</a>")
|
||||
|
||||
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("<a href='{% url 'delete_keyword' record.id %}' >" + _('Delete') + "</a>")
|
||||
|
||||
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("<a href='{% url 'delete_monitor' record.id %}' >" + _('Delete') + "</a>")
|
||||
|
||||
@staticmethod
|
||||
def render_path(value):
|
||||
|
@ -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 }}
|
||||
<input type="submit" value="Submit" class="btn btn-success">
|
||||
<a href="{% url 'redirect_delete' form.instance|get_class|lower form.instance.pk %}" class="btn btn-danger">{% trans 'Delete' %}</a>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -16,15 +16,18 @@
|
||||
{% if filter %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-search"></i> {% trans "Search" %}
|
||||
<i class="fas fa-search"></i> {% trans "Search" %} <input type="text" class="form-control">
|
||||
<a data-toggle="collapse" href="#collapse_search" role="button" aria-expanded="false" aria-controls="collapse_search">{% trans 'Advanced Search' %}</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="" method="get" id="search_form">
|
||||
{{ filter.form|crispy }}
|
||||
<input class="btn btn-primary" type="submit"/>
|
||||
<a href="#" onclick="window.location = window.location.pathname;"
|
||||
class="btn btn-warning">{% trans 'Reset' %}</a>
|
||||
</form>
|
||||
<div class="collapse" id="collapse_search">
|
||||
<div class="card-body">
|
||||
<form action="" method="get" id="search_form">
|
||||
{{ filter.form|crispy }}
|
||||
<input class="btn btn-primary" type="submit"/>
|
||||
<a href="#" onclick="window.location = window.location.pathname;"
|
||||
class="btn btn-warning">{% trans 'Reset' %}</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -24,6 +24,8 @@ urlpatterns = [
|
||||
path('edit/monitor/<int:pk>/', edit.MonitorUpdate.as_view(), name='edit_monitor'),
|
||||
path('edit/import/<int:pk>/', edit.ImportUpdate.as_view(), name='edit_import'),
|
||||
|
||||
path('redirect/delete/<slug:name>/<int:pk>/', edit.delete_redirect, name='redirect_delete'),
|
||||
|
||||
path('delete/recipe/<int:pk>/', edit.RecipeDelete.as_view(), name='delete_recipe'),
|
||||
path('delete/keyword/<int:pk>/', edit.KeywordDelete.as_view(), name='delete_keyword'),
|
||||
path('delete/category/<int:pk>/', edit.CategoryDelete.as_view(), name='delete_category'),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user