mirror of https://gitlab.crans.org/bde/nk20
use django_tables2 for transactionTemplate
This commit is contained in:
parent
62573a35df
commit
f4fe0c9866
|
@ -54,3 +54,14 @@ class AliasTable(tables.Table):
|
||||||
'td': {'class': 'col-sm-2'},
|
'td': {'class': 'col-sm-2'},
|
||||||
'a': {'class': 'btn btn-danger'}},
|
'a': {'class': 'btn btn-danger'}},
|
||||||
text='delete', accessor='pk')
|
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)
|
||||||
|
|
|
@ -8,9 +8,11 @@ from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import CreateView, ListView, UpdateView
|
from django.views.generic import CreateView, ListView, UpdateView
|
||||||
|
|
||||||
|
from django_tables2 import SingleTableView
|
||||||
|
|
||||||
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
|
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
|
||||||
from .models import Transaction, TransactionTemplate, Alias, TemplateTransaction
|
from .models import Transaction, TransactionTemplate, Alias, TemplateTransaction
|
||||||
|
from .tables import ButtonTable
|
||||||
|
|
||||||
class TransactionCreate(LoginRequiredMixin, CreateView):
|
class TransactionCreate(LoginRequiredMixin, CreateView):
|
||||||
"""
|
"""
|
||||||
|
@ -106,12 +108,12 @@ class TransactionTemplateCreateView(LoginRequiredMixin, CreateView):
|
||||||
form_class = TransactionTemplateForm
|
form_class = TransactionTemplateForm
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateListView(LoginRequiredMixin, ListView):
|
class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
|
||||||
"""
|
"""
|
||||||
List TransactionsTemplates
|
List TransactionsTemplates
|
||||||
"""
|
"""
|
||||||
model = TransactionTemplate
|
model = TransactionTemplate
|
||||||
form_class = TransactionTemplateForm
|
table = ButtonTable
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
|
class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
|
@ -1,23 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load pretty_money %}
|
{% load pretty_money %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<a class="btn btn-primary text-center" href="{% url 'note:template_create' %}">Créer un bouton</a>
|
||||||
<table class="table">
|
{% render_table table %}
|
||||||
<tr>
|
|
||||||
<td>ID</td><td>Nom</td>
|
|
||||||
<td>Destinataire</td>
|
|
||||||
<td>Montant</td>
|
|
||||||
<td>Catégorie</td>
|
|
||||||
</tr>
|
|
||||||
{% for object in object_list %}
|
|
||||||
<tr>
|
|
||||||
<td>{{object.pk}}</td>
|
|
||||||
<td><a href="{{object.get_absolute_url}}">{{ object.name }}</a></td>
|
|
||||||
<td>{{ object.destination }}</td>
|
|
||||||
<td>{{ object.amount | pretty_money }}</td>
|
|
||||||
<td>{{ object.template_type }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<a class="btn btn-primary" href="{% url 'note:template_create' %}">Créer un bouton</a>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue