From 8ecaef0daf22d2a195392de99b88bcd2b26029bc Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 21 Mar 2020 07:36:07 +0100 Subject: [PATCH] Add render button --- apps/treasury/tables.py | 17 +++++++++++------ apps/treasury/urls.py | 3 ++- apps/treasury/views.py | 9 ++++++++- templates/treasury/billing_list.html | 13 +------------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/apps/treasury/tables.py b/apps/treasury/tables.py index b0b4f1db..30cbb2e7 100644 --- a/apps/treasury/tables.py +++ b/apps/treasury/tables.py @@ -1,20 +1,25 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django_tables2 import tables +import django_tables2 as tables +from django_tables2 import A from .models import Billing class BillingTable(tables.Table): + id = tables.LinkColumn("treasury:billing_update", args=[A("pk")]) + + render = tables.LinkColumn("treasury:billing_render", + args=[A("pk")], + accessor="pk", + text="", + attrs={'a': {'class': 'fa fa-file-pdf-o'}}) + class Meta: attrs = { 'class': 'table table-condensed table-striped table-hover' } model = Billing template_name = 'django_tables2/bootstrap4.html' - fields = ('id', 'name', 'subject', 'acquitted', ) - row_attrs = { - 'class': 'table-row', - 'data-href': lambda record: record.pk - } \ No newline at end of file + fields = ('id', 'name', 'subject', 'acquitted', 'render', ) diff --git a/apps/treasury/urls.py b/apps/treasury/urls.py index 1ec061c9..3f28c0a0 100644 --- a/apps/treasury/urls.py +++ b/apps/treasury/urls.py @@ -3,11 +3,12 @@ from django.urls import path -from .views import BillingCreateView, BillingListView, BillingUpdateView +from .views import BillingCreateView, BillingListView, BillingUpdateView, BillingRenderView app_name = 'treasury' urlpatterns = [ path('billing/', BillingListView.as_view(), name='billing'), path('billing/create/', BillingCreateView.as_view(), name='billing_create'), path('billing//', BillingUpdateView.as_view(), name='billing_update'), + path('billing/render//', BillingRenderView.as_view(), name='billing_render'), ] diff --git a/apps/treasury/views.py b/apps/treasury/views.py index a07d1068..380b8fd7 100644 --- a/apps/treasury/views.py +++ b/apps/treasury/views.py @@ -3,6 +3,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import CreateView, UpdateView +from django.views.generic.base import View from django_tables2 import SingleTableView from .models import Billing @@ -32,4 +33,10 @@ class BillingUpdateView(LoginRequiredMixin, UpdateView): """ model = Billing fields = '__all__' - # form_class = ClubForm + # form_class = BillingForm + + +class BillingRenderView(View): + """ + Render Billing + """ diff --git a/templates/treasury/billing_list.html b/templates/treasury/billing_list.html index 1ba40557..749c0767 100644 --- a/templates/treasury/billing_list.html +++ b/templates/treasury/billing_list.html @@ -3,19 +3,8 @@ {% load i18n %} {% block content %} -{% render_table table %} +{% render_table table %} {% trans "New billing" %} {% endblock %} -{% block extrajavascript %} - -{% endblock %}