mirror of https://gitlab.crans.org/bde/nk20
Add render button
This commit is contained in:
parent
b030f5797f
commit
8ecaef0daf
|
@ -1,20 +1,25 @@
|
||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# 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
|
from .models import Billing
|
||||||
|
|
||||||
|
|
||||||
class BillingTable(tables.Table):
|
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:
|
class Meta:
|
||||||
attrs = {
|
attrs = {
|
||||||
'class': 'table table-condensed table-striped table-hover'
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
}
|
}
|
||||||
model = Billing
|
model = Billing
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('id', 'name', 'subject', 'acquitted', )
|
fields = ('id', 'name', 'subject', 'acquitted', 'render', )
|
||||||
row_attrs = {
|
|
||||||
'class': 'table-row',
|
|
||||||
'data-href': lambda record: record.pk
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import BillingCreateView, BillingListView, BillingUpdateView
|
from .views import BillingCreateView, BillingListView, BillingUpdateView, BillingRenderView
|
||||||
|
|
||||||
app_name = 'treasury'
|
app_name = 'treasury'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('billing/', BillingListView.as_view(), name='billing'),
|
path('billing/', BillingListView.as_view(), name='billing'),
|
||||||
path('billing/create/', BillingCreateView.as_view(), name='billing_create'),
|
path('billing/create/', BillingCreateView.as_view(), name='billing_create'),
|
||||||
path('billing/<int:pk>/', BillingUpdateView.as_view(), name='billing_update'),
|
path('billing/<int:pk>/', BillingUpdateView.as_view(), name='billing_update'),
|
||||||
|
path('billing/render/<int:pk>/', BillingRenderView.as_view(), name='billing_render'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.views.generic import CreateView, UpdateView
|
from django.views.generic import CreateView, UpdateView
|
||||||
|
from django.views.generic.base import View
|
||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
|
|
||||||
from .models import Billing
|
from .models import Billing
|
||||||
|
@ -32,4 +33,10 @@ class BillingUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
model = Billing
|
model = Billing
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
# form_class = ClubForm
|
# form_class = BillingForm
|
||||||
|
|
||||||
|
|
||||||
|
class BillingRenderView(View):
|
||||||
|
"""
|
||||||
|
Render Billing
|
||||||
|
"""
|
||||||
|
|
|
@ -3,19 +3,8 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% render_table table %}
|
{% render_table table %}
|
||||||
|
|
||||||
<a class="btn btn-primary" href="{% url 'treasury:billing_create' %}">{% trans "New billing" %}</a>
|
<a class="btn btn-primary" href="{% url 'treasury:billing_create' %}">{% trans "New billing" %}</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block extrajavascript %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
$(document).ready(function($) {
|
|
||||||
$(".table-row").click(function() {
|
|
||||||
window.document.location = $(this).data("href");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
Loading…
Reference in New Issue