From 4b01e892656d8b091b5db3ebae342ae226c2679b Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Wed, 17 Jan 2024 17:51:28 +0000 Subject: [PATCH] add resolution update --- fet2020/finance/forms.py | 27 +++++++++++++++++++ fet2020/finance/urls.py | 2 ++ fet2020/finance/views.py | 14 +++++++++- .../templates/finance/resolution_update.html | 27 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 fet2020/templates/finance/resolution_update.html diff --git a/fet2020/finance/forms.py b/fet2020/finance/forms.py index a3574fc6..aa5bd442 100644 --- a/fet2020/finance/forms.py +++ b/fet2020/finance/forms.py @@ -256,6 +256,33 @@ class ResolutionCreateForm(forms.ModelForm): self.fields["option"].autofocus = True +class ResolutionUpdateForm(forms.ModelForm): + class Meta: + model = Resolution + + fields = [ + "option", + "name", + "date", + "voting", + "voting_text", + ] + + labels = { + "option": "Beschluss", + "date": "Datum", + "voting": "Abstimmungsverhalten", + "voting_text": "Abstimmungstext", + } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set + + self.fields["date"].disabled = True + + self.fields["option"].autofocus = True + + class BillInlineForm(forms.ModelForm): class Meta: fields = [ diff --git a/fet2020/finance/urls.py b/fet2020/finance/urls.py index cb8d653f..7fef2627 100644 --- a/fet2020/finance/urls.py +++ b/fet2020/finance/urls.py @@ -8,6 +8,7 @@ from .views import ( BillUpdateView, ResolutionCreateView, ResolutionListView, + ResolutionUpdateView, ) app_name = apps.FinanceConfig.name @@ -25,4 +26,5 @@ urlpatterns = [ "create-resolution/", ResolutionCreateView.as_view(), name="resolution_create" ), path("resolutions/", ResolutionListView.as_view(), name="resolution_list"), + path("resolutions//", ResolutionUpdateView.as_view(), name="resolution_update"), ] diff --git a/fet2020/finance/views.py b/fet2020/finance/views.py index a11d6eab..dfd8b9b5 100644 --- a/fet2020/finance/views.py +++ b/fet2020/finance/views.py @@ -6,7 +6,7 @@ from django.views.generic.edit import CreateView, UpdateView from fet2020.utils import add_log_action -from .forms import BillCreateForm, BillUpdateForm, ResolutionCreateForm +from .forms import BillCreateForm, BillUpdateForm, ResolutionCreateForm, ResolutionUpdateForm from .models import BankData, Bill, Resolution @@ -100,3 +100,15 @@ class ResolutionCreateView(LoginRequiredMixin, CreateView): class ResolutionListView(LoginRequiredMixin, ListView): model = Resolution template_name = "finance/resolution_list.html" + + +class ResolutionUpdateView(LoginRequiredMixin, UpdateView): + form_class = ResolutionUpdateForm + model = Resolution + pk_url_kwarg = 'id' + success_url = reverse_lazy("finance:resolution_list") + template_name = "finance/resolution_update.html" + + def form_valid(self, form): + add_log_action(self.request, form, "finance", "resolution", False) + return super().form_valid(form) diff --git a/fet2020/templates/finance/resolution_update.html b/fet2020/templates/finance/resolution_update.html new file mode 100644 index 00000000..91c9a25d --- /dev/null +++ b/fet2020/templates/finance/resolution_update.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} + +{% block title %}Beschluss {{ object.id }}{% endblock %} + +{% block content %} + +
+

Beschluss {{ object.id }}

+
+
+ {% csrf_token %} + + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/select.html" with field=form.option %} + {% include "baseform/text.html" with field=form.name %} + {% include "baseform/text.html" with field=form.date %} + {% include "baseform/text.html" with field=form.voting %} + {% include "baseform/textarea.html" with field=form.voting_text %} + +
+ +
+
+
+
+{% endblock %}