create subpages
This commit is contained in:
parent
dc0440fcef
commit
aac1cdb118
9 changed files with 184 additions and 3 deletions
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib import admin
|
||||
from .models import PublicBody, Party, Member, Question, Answer
|
||||
from .models import PublicBody, Party, Member, Question, Answer, Vote
|
||||
|
||||
|
||||
@admin.register(PublicBody)
|
||||
|
|
@ -33,4 +33,11 @@ class QuestionAdmin(admin.ModelAdmin):
|
|||
class AnswerAdmin(admin.ModelAdmin):
|
||||
list_display = ("question", "answered_by", "created_at")
|
||||
list_filter = ("answered_by",)
|
||||
search_fields = ("body",)
|
||||
search_fields = ("body",)
|
||||
|
||||
|
||||
@admin.register(Vote)
|
||||
class VoteAdmin(admin.ModelAdmin):
|
||||
list_display = ("title", "public_body", "date")
|
||||
list_filter = ("public_body", "date")
|
||||
search_fields = ("title", "description")
|
||||
31
council/migrations/0002_vote.py
Normal file
31
council/migrations/0002_vote.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 4.2.23 on 2025-08-21 07:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('council', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Vote',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('date', models.DateField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('members', models.ManyToManyField(blank=True, related_name='votes', to='council.member')),
|
||||
('public_body', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='council.publicbody')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Abstimmung',
|
||||
'verbose_name_plural': 'Abstimmungen',
|
||||
'ordering': ['-date', '-created_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
BIN
council/migrations/__pycache__/0002_vote.cpython-312.pyc
Normal file
BIN
council/migrations/__pycache__/0002_vote.cpython-312.pyc
Normal file
Binary file not shown.
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
36
templates/council/member_detail.html
Normal file
36
templates/council/member_detail.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}{{ member }} – Stadträt:in{% endblock %}
|
||||
{% block content %}
|
||||
<h2 class="mb-1">{{ member.first_name }} {{ member.last_name }}</h2>
|
||||
<p class="text-muted mb-3">
|
||||
{% if member.public_body %}in <a href="{% url 'public_body_detail' slug=member.public_body.slug %}">{{ member.public_body.name }}</a>{% endif %}
|
||||
{% if member.party %} • {{ member.party }} (<a href="{% url 'party_detail' pk=member.party.id %}">Profil</a>){% endif %}
|
||||
</p>
|
||||
|
||||
<h3 class="mt-4">Fragen an {{ member.first_name }}</h3>
|
||||
<ul class="list-group mb-4">
|
||||
{% for q in questions %}
|
||||
<li class="list-group-item">
|
||||
<strong>{{ q.title }}</strong>
|
||||
<div class="text-muted">{{ q.created_at|date:'d.m.Y H:i' }}</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Fragen.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3 class="mt-4">Abstimmungen (Beteiligung)</h3>
|
||||
<ul class="list-group">
|
||||
{% for v in votes %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span>
|
||||
<strong>{{ v.title }}</strong>
|
||||
{% if v.date %}<span class="text-muted ms-2">({{ v.date|date:'d.m.Y' }})</span>{% endif %}
|
||||
</span>
|
||||
<span class="text-muted">{{ v.public_body.name }}</span>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Abstimmungen.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
</a>
|
||||
{% if p.abbreviation %}<span class="text-muted ms-2">({{ p.abbreviation }})</span>{% endif %}
|
||||
</span>
|
||||
{% if p.color %}<span class="badge" style="background-color: {{ p.color }}"> </span>{% endif %}
|
||||
{% if p.color %}<span class="badge" style="background-color: {{ p.color }};"> </span>{% endif %}
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Einträge.</li>
|
||||
|
|
|
|||
51
templates/council/party_detail.html
Normal file
51
templates/council/party_detail.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}{{ party.name }} – Partei{% endblock %}
|
||||
{% block content %}
|
||||
<h2 class="mb-1">{{ party.name }}</h2>
|
||||
{% if party.abbreviation %}<p class="text-muted">Kurz: {{ party.abbreviation }}</p>{% endif %}
|
||||
|
||||
<h3 class="mt-4">Gemeinden</h3>
|
||||
<ul class="list-group mb-3">
|
||||
{% for g in public_bodies %}
|
||||
<li class="list-group-item">
|
||||
<a href="{% url 'public_body_detail' slug=g.slug %}">{{ g.name }}</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Gemeinden.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3 class="mt-4">Stadträt:innen</h3>
|
||||
<div class="table-responsive mb-3">
|
||||
<table class="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Gemeinde</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for m in members %}
|
||||
<tr>
|
||||
<td><a href="{% url 'member_detail' pk=m.id %}">{{ m.first_name }} {{ m.last_name }}</a></td>
|
||||
<td>{% if m.public_body %}<a href="{% url 'public_body_detail' slug=m.public_body.slug %}">{{ m.public_body.name }}</a>{% else %}–{% endif %}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan="2">Keine Mitglieder.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3 class="mt-4">Fragen</h3>
|
||||
<ul class="list-group">
|
||||
{% for q in questions %}
|
||||
<li class="list-group-item">
|
||||
<strong>{{ q.title }}</strong>
|
||||
<div class="text-muted">an <a href="{% url 'member_detail' pk=q.member.id %}">{{ q.member }}</a> • {{ q.created_at|date:'d.m.Y H:i' }}</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Fragen.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
56
templates/council/public_body_detail.html
Normal file
56
templates/council/public_body_detail.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}{{ body.name }} – Gemeinde{% endblock %}
|
||||
{% block content %}
|
||||
<h2 class="mb-3">{{ body.name }}</h2>
|
||||
{% if body.website %}<p><a href="{{ body.website }}" target="_blank" rel="noopener">Webseite</a></p>{% endif %}
|
||||
{% if body.description %}<p class="text-muted">{{ body.description }}</p>{% endif %}
|
||||
|
||||
<h3 class="mt-4">Parteien in {{ body.name }}</h3>
|
||||
<ul class="list-group mb-3">
|
||||
{% for p in parties %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="{% url 'party_detail' pk=p.id %}" class="text-decoration-none"><strong>{{ p.name }}</strong></a>
|
||||
{% if p.color %}<span class="badge" style="background-color: {{ p.color }}"> </span>{% endif %}
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Parteien.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3 class="mt-4">Stadträt:innen</h3>
|
||||
<div class="table-responsive mb-3">
|
||||
<table class="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Partei</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for m in members %}
|
||||
<tr>
|
||||
<td><a href="{% url 'member_detail' pk=m.id %}">{{ m.first_name }} {{ m.last_name }}</a></td>
|
||||
<td>{% if m.party %}<a href="{% url 'party_detail' pk=m.party.id %}">{{ m.party }}</a>{% else %}–{% endif %}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan="2">Keine Mitglieder.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3 class="mt-4">Abstimmungen</h3>
|
||||
<ul class="list-group">
|
||||
{% for v in votes %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span>
|
||||
<strong>{{ v.title }}</strong>
|
||||
{% if v.date %}<span class="text-muted ms-2">({{ v.date|date:'d.m.Y' }})</span>{% endif %}
|
||||
</span>
|
||||
<span class="badge bg-secondary">{{ v.members.count }} Beteiligte</span>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">Keine Abstimmungen.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue