add detail

This commit is contained in:
2024-02-04 21:45:56 +00:00
parent c219059cb3
commit dcc9f13804
5 changed files with 102 additions and 7 deletions

View File

@@ -354,6 +354,9 @@ class ResolutionCreateForm(forms.ModelForm):
self.fields["option"].autofocus = True
self.fields["voting_text"].cols = 30
self.fields["voting_text"].rows = 3
class ResolutionUpdateForm(forms.ModelForm):
class Meta:
@@ -381,6 +384,15 @@ class ResolutionUpdateForm(forms.ModelForm):
self.fields["option"].autofocus = True
# Config for textarea of comment. Calc rows for a better view.
self.fields["voting_text"].cols = 30
rows = (
len(kwargs["instance"].voting_text) / 90
+ kwargs["instance"].voting_text.count("\n")
+ 1
)
self.fields["voting_text"].rows = rows
class BillInlineForm(forms.ModelForm):
class Meta:

View File

@@ -7,6 +7,7 @@ from .views import (
BillListView,
BillUpdateView,
ResolutionCreateView,
ResolutionDetailView,
ResolutionListView,
ResolutionUpdateView,
)
@@ -29,4 +30,9 @@ urlpatterns = [
ResolutionUpdateView.as_view(),
name="resolution_update",
),
path(
"resolutions/<str:id>/detail/",
ResolutionDetailView.as_view(),
name="resolution_detail",
),
]

View File

@@ -3,9 +3,11 @@ from django.db.models import Q
from django.shortcuts import redirect
from django.urls import reverse, reverse_lazy
from django.views.generic import ListView, TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from fet2020.utils import add_log_action
from posts.models import FetMeeting
from .forms import (
BillCreateForm,
@@ -120,6 +122,21 @@ class ResolutionCreateView(LoginRequiredMixin, CreateView):
return super().form_valid(form)
class ResolutionDetailView(LoginRequiredMixin, DetailView):
model = Resolution
pk_url_kwarg = "id"
template_name = "finance/resolution_detail.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["fetmeeting"] = (
FetMeeting.objects.get_queryset().filter(date=self.object.date).first()
)
return context
class ResolutionListView(LoginRequiredMixin, ListView):
model = Resolution
template_name = "finance/resolution_list.html"

View File

@@ -0,0 +1,60 @@
{% 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 max-w-2xl">
<h1 class="page-title">Beschluss {{ object.id }}</h1>
<section>
<div class="grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6">
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Bezeichnung</h2>
<p class="text-gray-700 dark:text-gray-200">{{ object.name }}</p>
</label>
</div>
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Abstimmungstext</h2>
<p class="text-gray-700 dark:text-gray-200">{{ object.voting_text|safe }}</p>
</label>
</div>
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Option</h2>
<p class="text-gray-700 dark:text-gray-200">{{ object.get_option_display }}</p>
</label>
</div>
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Datum</h2>
<p class="text-gray-700 dark:text-gray-200">{{ object.date }}</p>
</label>
</div>
{% if fetmeeting %}
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Fachschaftsitzung</h2>
<div class="text-blue-700 dark:text-blue-200 underline">
<a href="{{ fetmeeting.get_absolute_url }}">Link zur {{ fetmeeting.title }}</a>
</div>
</label>
</div>
{% endif %}
<div class="col-span-full">
<label>
<h2 class="text-xl font-black text-gray-700 dark:text-gray-200">Abstimmungsverhalten</h2>
<p class="text-gray-700 dark:text-gray-200">{{ object.voting }}</p>
</label>
</div>
</div>
</section>
<section class="flex justify-end">
<a class="btn btn-small btn-primary" href="{% url 'finance:resolution_update' object.id %}">
<i class="fa-solid fa-pen-to-square mr-1"></i>Beschluss bearbeiten
</a>
</section>
</main>
{% endblock %}

View File

@@ -10,14 +10,14 @@
<i class="fa-solid fa-plus mr-1"></i> Beschluss eingeben
</a>
<div class="mx-auto max-w-5xl">
<div class="mx-auto max-w-5xl">
<div class="overflow-x-scroll shadow rounded">
<table class="w-full">
<thead>
<tr>
<th class="text-left">Nummer</th>
<th class="text-left">Bezeichnung</th>
<th class="text-left">Abstimmungstext</th>
<!--<th class="text-left">Abstimmungstext</th>-->
<th class="text-left">Abstimmungsverhalten</th>
<th class="text-left">Beschluss</th>
<th></th>
@@ -27,8 +27,8 @@
{% for result in object_list %}
<tr>
<td class="text-right">{{ result.id }}</td>
<td>{{ result.name }}</td>
<td class="text-left">{{ result.voting_text }}</td>
<td class="text-blue-700 dark:text-blue-200 underline"><a href="{%url 'finance:resolution_detail' result.id %}">{{ result.name }}</a></td>
<!--<td class="text-left">{{ result.voting_text|truncatechars:300 }}</td>-->
<td class="text-left">{{ result.voting }}</td>
<td class="text-left">{{ result.get_option_display }}</td>
<td>
@@ -39,7 +39,7 @@
</tbody>
</table>
</div>
{% if is_paginated %}
<div class="mt-4 w-full flex flex-col-reverse sm:flex-row gap-y-4 justify-between items-center">
<div class="pagination-container">
@@ -49,11 +49,11 @@
<a href="?page={{ page_obj.previous_page_number }}"><i class="fa-solid fa-arrow-left" aria-label="Eine Seite zurück"></i> Zurück</a>
<a href="?page=1">1</a>
{% endif %}
<span class="current active">
<a href="#" class="active">{{ page_obj.number }}</a>
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.paginator.num_pages }}">{{ page_obj.paginator.num_pages }}</a>
<a href="?page={{ page_obj.next_page_number }}">Vor <i class="fa-solid fa-arrow-right" aria-label="Eine Seite vor"></i></a>