{% 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 }}">&nbsp;&nbsp;&nbsp;</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 %} 