From b030f5797f0600af4396f9cb958272b929e3dcca Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 21 Mar 2020 00:52:26 +0100 Subject: [PATCH] Create & update billings (products are not yet supported) --- apps/treasury/urls.py | 4 +++- apps/treasury/views.py | 19 +++++++++++++++++++ templates/treasury/billing_form.html | 12 ++++++++++++ templates/treasury/billing_list.html | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 templates/treasury/billing_form.html diff --git a/apps/treasury/urls.py b/apps/treasury/urls.py index 7cd68ec0..1ec061c9 100644 --- a/apps/treasury/urls.py +++ b/apps/treasury/urls.py @@ -3,9 +3,11 @@ from django.urls import path -from .views import BillingListView +from .views import BillingCreateView, BillingListView, BillingUpdateView 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'), ] diff --git a/apps/treasury/views.py b/apps/treasury/views.py index 435f8cdb..a07d1068 100644 --- a/apps/treasury/views.py +++ b/apps/treasury/views.py @@ -2,15 +2,34 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.contrib.auth.mixins import LoginRequiredMixin +from django.views.generic import CreateView, UpdateView from django_tables2 import SingleTableView from .models import Billing from .tables import BillingTable +class BillingCreateView(LoginRequiredMixin, CreateView): + """ + Create Billing + """ + model = Billing + fields = '__all__' + # form_class = ClubForm + + class BillingListView(LoginRequiredMixin, SingleTableView): """ List existing Billings """ model = Billing table_class = BillingTable + + +class BillingUpdateView(LoginRequiredMixin, UpdateView): + """ + Create Billing + """ + model = Billing + fields = '__all__' + # form_class = ClubForm diff --git a/templates/treasury/billing_form.html b/templates/treasury/billing_form.html new file mode 100644 index 00000000..d72e15c5 --- /dev/null +++ b/templates/treasury/billing_form.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load static %} +{% load i18n %} +{% load crispy_forms_tags %} +{% block content %} +

{% trans "Billings list" %}

+
+{% csrf_token %} +{{form|crispy}} + +
+{% endblock %} diff --git a/templates/treasury/billing_list.html b/templates/treasury/billing_list.html index 1cc473f1..1ba40557 100644 --- a/templates/treasury/billing_list.html +++ b/templates/treasury/billing_list.html @@ -5,7 +5,7 @@ {% render_table table %} -{% trans "New billing" %} +{% trans "New billing" %} {% endblock %} {% block extrajavascript %}