add resolution update
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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/<str:id>/", ResolutionUpdateView.as_view(), name="resolution_update"),
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
|
||||
27
fet2020/templates/finance/resolution_update.html
Normal file
27
fet2020/templates/finance/resolution_update.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Beschluss {{ object.id }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Main Content -->
|
||||
<main class="container mx-auto w-full px-4 my-8 flex-1">
|
||||
<h1 class="page-title">Beschluss {{ object.id }}</h1>
|
||||
<div class="w-full h-full flex-1 flex justify-center items-center">
|
||||
<form action="" enctype="multipart/form-data" method="POST" class="w-full max-w-xs sm:max-w-prose sm:px-28 sm:py-4 grid grid-cols-1 gap-y-3 sm:gap-y-6 text-gray-900">
|
||||
{% 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 %}
|
||||
|
||||
<div class="flex flex-col-reverse sm:flex-row gap-3 justify-end pt-4 sm:pt-0">
|
||||
<input type="submit" class="block btn btn-primary" value="Speichern">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user