diff --git a/apps/note/tables.py b/apps/note/tables.py index e85fcbae..580cb91d 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -54,3 +54,14 @@ class AliasTable(tables.Table): 'td': {'class': 'col-sm-2'}, 'a': {'class': 'btn btn-danger'}}, text='delete', accessor='pk') + +class ButtonTable(tables.Table): + class Meta: + attrs = { + 'class': + 'table table condensed table-striped table-hover' + } + model = TransactionTemplate + + def render_amount(self, value): + return pretty_money(value) diff --git a/apps/note/views.py b/apps/note/views.py index 09846057..a3441ab3 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -8,9 +8,11 @@ from django.urls import reverse from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, ListView, UpdateView +from django_tables2 import SingleTableView + from .forms import TransactionForm, TransactionTemplateForm, ConsoForm from .models import Transaction, TransactionTemplate, Alias, TemplateTransaction - +from .tables import ButtonTable class TransactionCreate(LoginRequiredMixin, CreateView): """ @@ -106,12 +108,12 @@ class TransactionTemplateCreateView(LoginRequiredMixin, CreateView): form_class = TransactionTemplateForm -class TransactionTemplateListView(LoginRequiredMixin, ListView): +class TransactionTemplateListView(LoginRequiredMixin, SingleTableView): """ List TransactionsTemplates """ model = TransactionTemplate - form_class = TransactionTemplateForm + table = ButtonTable class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView): diff --git a/templates/note/transactiontemplate_list.html b/templates/note/transactiontemplate_list.html index 62e4d164..e8881988 100644 --- a/templates/note/transactiontemplate_list.html +++ b/templates/note/transactiontemplate_list.html @@ -1,23 +1,7 @@ {% extends "base.html" %} {% load pretty_money %} +{% load render_table from django_tables2 %} {% block content %} - - - - - - - - -{% for object in object_list %} - - - - - - - -{% endfor %} -
IDNomDestinataireMontantCatégorie
{{object.pk}}{{ object.name }}{{ object.destination }}{{ object.amount | pretty_money }}{{ object.template_type }}
-Créer un bouton +Créer un bouton +{% render_table table %} {% endblock %}