SielBotWebsite/templates/poll_detail.html
Maaxxs a6e3133e06 Abstimmungen: anlegen, Ergebnis mit Balken, beenden und löschen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 08:12:09 +02:00

70 lines
3.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block title %}Abstimmung{% endblock %}
{% block content %}
<div class="page-head">
<a href="/abstimmungen" class="back-link">← Alle Abstimmungen</a>
<h1>📊 {{ poll.question }}
{% if poll.status == "open" %}<span class="tag tag-green">Läuft</span>{% else %}<span class="tag">Beendet</span>{% endif %}
</h1>
<p class="muted">
# {{ poll.channel_name or "?" }} · gestartet {{ poll.created_at | datetime }}{% if poll.created_by %} von {{ poll.created_by }}{% endif %}
· {% if poll.status == "open" %}{% if poll.ends_at %}endet {{ poll.ends_at | datetime }}{% else %}ohne Ende{% endif %}{% else %}beendet {{ poll.ended_at | datetime }}{% endif %}
{% if poll.message_url %}· <a href="{{ poll.message_url }}" target="_blank" rel="noopener">Im Discord öffnen</a>{% endif %}
</p>
</div>
{% if poll.description %}<p>{{ poll.description }}</p>{% endif %}
<section class="panel">
<h2>Ergebnis <span class="muted">· {{ poll.voters }} {{ "Person" if poll.voters == 1 else "Personen" }}</span></h2>
{% set total = poll.counts | sum %}
{% set top = poll.counts | max %}
<div class="poll-results">
{% for o in poll.options %}
{% set n = poll.counts[loop.index0] %}
{% set pct = (100 * n / total) | round | int if total else 0 %}
<div class="poll-result{% if n == top and total %} poll-top{% endif %}">
<div class="poll-result-head"><span>{{ o.emoji or loop.index ~ "." }} <strong>{{ o.label }}</strong></span><span>{{ pct }} % · {{ n }}</span></div>
<div class="poll-bar"><span data-pct="{{ pct }}"></span></div>
</div>
{% endfor %}
</div>
<p class="muted small">
{{ "Mehrere Stimmen pro Person (bis " ~ poll.max_choices ~ ")" if poll.max_choices > 1 else "Eine Stimme pro Person" }}
· {{ "anonym" if poll.anonymous else "nicht anonym" }}
· Ergebnis {{ "live sichtbar" if poll.live_results else "erst am Ende sichtbar" }}
</p>
</section>
{% if poll.votes is defined and poll.votes %}
<section class="panel">
<h2>Wer hat was gewählt</h2>
<div class="table-wrap">
<table class="table">
<thead><tr><th>Person</th><th>Antwort</th><th>Wann</th></tr></thead>
<tbody>
{% for v in poll.votes %}
<tr><td>{{ v.user_name }}</td><td>{{ poll.options[v.option_idx].label if v.option_idx < poll.options | length else "?" }}</td><td class="small">{{ v.voted_at | datetime }}</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% elif poll.anonymous %}
<p class="muted small">Anonyme Abstimmung – wer was gewählt hat, wird nirgends angezeigt.</p>
{% endif %}
<div class="actions-row">
{% if poll.status == "open" %}
<form method="post" action="/abstimmungen/{{ poll.id }}/beenden" data-confirm="Abstimmung jetzt beenden? Danach kann niemand mehr abstimmen.">
<input type="hidden" name="csrf" value="{{ csrf }}">
<button type="submit" class="btn">Jetzt beenden</button>
</form>
{% endif %}
<form method="post" action="/abstimmungen/{{ poll.id }}/loeschen" data-confirm="Abstimmung löschen? Die Nachricht verschwindet auch aus dem Discord, die Stimmen sind weg.">
<input type="hidden" name="csrf" value="{{ csrf }}">
<button type="submit" class="btn btn-danger">Löschen</button>
</form>
</div>
<script src="/static/js/confirm.js?v=1"></script>
<script src="/static/js/polls.js?v=1"></script>
{% endblock %}