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'}})
|
attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}})
|
||||||
all_tags = tables.Column(
|
all_tags = tables.Column(
|
||||||
attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}})
|
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:
|
class Meta:
|
||||||
model = Recipe
|
model = Recipe
|
||||||
@ -25,7 +23,6 @@ class RecipeTable(tables.Table):
|
|||||||
|
|
||||||
class CategoryTable(tables.Table):
|
class CategoryTable(tables.Table):
|
||||||
id = tables.LinkColumn('edit_category', args=[A('id')])
|
id = tables.LinkColumn('edit_category', args=[A('id')])
|
||||||
delete = tables.TemplateColumn("<a href='{% url 'delete_category' record.id %}' >" + _('Delete') + "</a>")
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Category
|
model = Category
|
||||||
@ -35,7 +32,6 @@ class CategoryTable(tables.Table):
|
|||||||
|
|
||||||
class KeywordTable(tables.Table):
|
class KeywordTable(tables.Table):
|
||||||
id = tables.LinkColumn('edit_keyword', args=[A('id')])
|
id = tables.LinkColumn('edit_keyword', args=[A('id')])
|
||||||
delete = tables.TemplateColumn("<a href='{% url 'delete_keyword' record.id %}' >" + _('Delete') + "</a>")
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Keyword
|
model = Keyword
|
||||||
@ -61,7 +57,6 @@ class ImportLogTable(tables.Table):
|
|||||||
|
|
||||||
class MonitoredPathTable(tables.Table):
|
class MonitoredPathTable(tables.Table):
|
||||||
id = tables.LinkColumn('edit_monitor', args=[A('id')])
|
id = tables.LinkColumn('edit_monitor', args=[A('id')])
|
||||||
delete = tables.TemplateColumn("<a href='{% url 'delete_monitor' record.id %}' >" + _('Delete') + "</a>")
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def render_path(value):
|
def render_path(value):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load class_tag %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
||||||
|
|
||||||
@ -16,6 +17,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form|crispy }}
|
{{ form|crispy }}
|
||||||
<input type="submit" value="Submit" class="btn btn-success">
|
<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>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -16,15 +16,18 @@
|
|||||||
{% if filter %}
|
{% if filter %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<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>
|
||||||
<div class="card-body">
|
<div class="collapse" id="collapse_search">
|
||||||
<form action="" method="get" id="search_form">
|
<div class="card-body">
|
||||||
{{ filter.form|crispy }}
|
<form action="" method="get" id="search_form">
|
||||||
<input class="btn btn-primary" type="submit"/>
|
{{ filter.form|crispy }}
|
||||||
<a href="#" onclick="window.location = window.location.pathname;"
|
<input class="btn btn-primary" type="submit"/>
|
||||||
class="btn btn-warning">{% trans 'Reset' %}</a>
|
<a href="#" onclick="window.location = window.location.pathname;"
|
||||||
</form>
|
class="btn btn-warning">{% trans 'Reset' %}</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -24,6 +24,8 @@ urlpatterns = [
|
|||||||
path('edit/monitor/<int:pk>/', edit.MonitorUpdate.as_view(), name='edit_monitor'),
|
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('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/recipe/<int:pk>/', edit.RecipeDelete.as_view(), name='delete_recipe'),
|
||||||
path('delete/keyword/<int:pk>/', edit.KeywordDelete.as_view(), name='delete_keyword'),
|
path('delete/keyword/<int:pk>/', edit.KeywordDelete.as_view(), name='delete_keyword'),
|
||||||
path('delete/category/<int:pk>/', edit.CategoryDelete.as_view(), name='delete_category'),
|
path('delete/category/<int:pk>/', edit.CategoryDelete.as_view(), name='delete_category'),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy, reverse
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views.generic import UpdateView, DeleteView
|
from django.views.generic import UpdateView, DeleteView
|
||||||
@ -95,6 +96,11 @@ class RecipeUpdate(LoginRequiredMixin, UpdateView):
|
|||||||
|
|
||||||
|
|
||||||
# Generic Delete views
|
# Generic Delete views
|
||||||
|
|
||||||
|
def delete_redirect(request, name, pk):
|
||||||
|
return redirect(('delete_' + name), pk)
|
||||||
|
|
||||||
|
|
||||||
class RecipeDelete(LoginRequiredMixin, DeleteView):
|
class RecipeDelete(LoginRequiredMixin, DeleteView):
|
||||||
template_name = "generic\delete_template.html"
|
template_name = "generic\delete_template.html"
|
||||||
model = Recipe
|
model = Recipe
|
||||||
|
Loading…
Reference in New Issue
Block a user