add resolution update

This commit is contained in:
2024-01-17 17:51:28 +00:00
parent 9292eaf1cf
commit 4b01e89265
4 changed files with 69 additions and 1 deletions

View File

@@ -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 = [

View File

@@ -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"),
]

View File

@@ -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)