From d1964947efeba4738bb87f10f4660393efe2b253 Mon Sep 17 00:00:00 2001 From: H4nSolo Date: Thu, 22 Oct 2026 22:04:06 +0200 Subject: [PATCH] gd2-Startseite im neuen Design, Intern-Dashboard mit Statistiken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gd2: Startseite neu gestaltet (Hero, Video-Beiträge, Top-Fragen, Frage des Tages, Promo-Zahlen); Inhalte sind noch Platzhalter im Code - intern: Dashboard mit Kennzahlen und Chart.js-Diagrammen (Folgen/Fragen pro Jahr, Kategorien, Einsender nach Stadt/Bundesland/Land, Team-Auftritte, Top-Löser, Zuschauer- vs. Archivfragen); Analyse und Folgenliste erweitert - intern: Count(..., distinct=True) bei Auftritten sowie Panel-/Fragen-Durchschnitt, sonst wurden die Werte durch den Join multipliziert (z. B. 41.730 statt 195) Co-Authored-By: Claude Opus 5.5 --- gd2/static/gd2/css/style.css | 552 +++++++++++++++++------ gd2/templates/gd2/home.html | 221 +++------ gd2/views.py | 40 +- intern/templates/intern/analyse.html | 115 +++++ intern/templates/intern/dashboard.html | 289 +++++++++++- intern/templates/intern/folge_liste.html | 7 +- intern/views.py | 160 ++++++- 7 files changed, 1067 insertions(+), 317 deletions(-) diff --git a/gd2/static/gd2/css/style.css b/gd2/static/gd2/css/style.css index a5c7946..cf54a57 100644 --- a/gd2/static/gd2/css/style.css +++ b/gd2/static/gd2/css/style.css @@ -1,160 +1,456 @@ -/* ========================================================================== - 1. VARIABLEN & BASICS - ========================================================================== */ :root { - --genial-orange: #f15a24; - --genial-gradient: linear-gradient(135deg, #f15a24 0%, #ff922b 100%); - --body-bg: #fceee4; - --text-color: #333; - --header-max-width: 1318px; + --gd-orange: #f15a24; + --gd-orange-deep: #d54b20; + --gd-beige: #f6efe9; + --gd-warm: #f1c58f; + --gd-text: #2a1c1a; + --gd-white: #fffaf6; +} + +* { + box-sizing: border-box; } body { - font-family: 'Montserrat', sans-serif; - background-color: var(--body-bg); - color: var(--text-color); - margin: 0; - padding: 0; - overflow-x: hidden; /* Verhindert seitliches Scrollen durch Clip-Paths */ + margin: 0; + font-family: 'Montserrat', sans-serif; + background: #f3ece6; + color: var(--gd-text); + overflow-x: hidden; } -/* ========================================================================== - 2. HEADER & HERO-SECTION - ========================================================================== */ -header { - width: 100%; - display: flex; - justify-content: center; - background-color: var(--body-bg); +img { + max-width: 100%; + display: block; } -.hero-section { - width: 100%; - max-width: var(--header-max-width); - background: var(--genial-gradient); - position: relative; - color: white; - overflow: hidden; - z-index: 0; - padding-bottom: 120px; - box-shadow: 0 10px 30px rgba(0,0,0,0.1); +button, a { + font: inherit; } -.top-banner-bg { - background: url('../img/header.png') no-repeat top center; - background-size: cover; - width: 100%; - height: 221px; - position: relative; - z-index: 1; +.site-header { + width: 100%; + background: #f3ece6; + display: flex; + justify-content: center; + padding-bottom: 0; } -/* Untere organische Kurve */ -.hero-section::after { - content: ""; - position: absolute; - bottom: -1px; - left: 0; - width: 100%; - height: 60px; - background-color: var(--body-bg); - clip-path: ellipse(60% 100% at 50% 100%); - z-index: 2; +.header-banner { + width: 100%; + min-height: 420px; + background: url('/static/gd/img/header_full.png') center top / cover no-repeat; + position: relative; + overflow: hidden; + box-shadow: inset 0 -22px 0 rgba(255,255,255,0.18); } -/* ========================================================================== - 3. NAVIGATION & TICKER - ========================================================================== */ -.navbar { - position: absolute; - top: 45px; - width: 100%; - z-index: 10; +.header-brand-wrap { + width: min(100%, 1280px); + margin: 0 auto; + padding-top: 20px; + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + position: relative; + z-index: 2; } -.header-marquee { - position: absolute; - top: 2px; - /* Optimierung: Flexiblere Positionierung */ - left: 21%; - right: 2px; - color: white; - font-size: 0.85rem; - padding: 5px 0; - z-index: 15; - font-weight: 500; - text-transform: uppercase; - letter-spacing: 1px; - white-space: nowrap; - overflow: hidden; - clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 2% 100%); +.brand-logo { + display: flex; + flex-direction: column; + justify-content: center; + min-width: 260px; + padding-left: 12px; + color: #fff; + text-shadow: 0 2px 12px rgba(0,0,0,0.18); + line-height: 0.82; } -/* ========================================================================== - 4. KOMPONENTEN (CARDS, BUTTONS) - ========================================================================== */ - -/* Glassmorphismus Card */ -.glass-card { - background: rgba(255, 255, 255, 0.6) !important; - backdrop-filter: blur(15px); - -webkit-backdrop-filter: blur(15px); - border-radius: 30px !important; - border: 1px solid rgba(255, 255, 255, 0.3) !important; - transition: all 0.3s ease; +.brand-genial { + font-weight: 900; + font-size: clamp(2.5rem, 3vw, 4.1rem); + letter-spacing: -0.05em; } -.section-header-orange { - background: var(--genial-gradient); - color: white; - padding: 12px 25px; - border-radius: 15px 15px 0 0; - /* Korrektur: Margin-Ausgleich für Card-Padding */ - margin: -25px -25px 20px -25px; +.brand-daneben { + font-weight: 900; + font-size: clamp(2.3rem, 2.6vw, 3.7rem); + letter-spacing: -0.05em; + margin-top: -4px; } -/* Buttons */ -.btn-pill { - border-radius: 50px !important; - padding: 10px 30px !important; - font-weight: 700 !important; - text-transform: uppercase; - font-size: 0.9rem; +.header-nav { + display: flex; + align-items: center; + justify-content: center; + gap: 2.1rem; + background: rgba(255,255,255,0.12); + border-radius: 20px 20px 0 0; + padding: 0.8rem 1rem 0.9rem; + margin-left: auto; + margin-right: auto; + backdrop-filter: blur(3px); } -.btn-genial { - background: var(--genial-gradient); - color: white !important; - border: none !important; - box-shadow: 0 4px 15px rgba(241, 90, 36, 0.2); - transition: all 0.2s ease; +.header-nav a { + color: rgba(255,255,255,0.96); + text-decoration: none; + font-weight: 700; + font-size: 0.95rem; + position: relative; + line-height: 1; } -.btn-genial:hover { - transform: translateY(-2px); - box-shadow: 0 8px 25px rgba(241, 90, 36, 0.4); - filter: brightness(1.1); +.header-nav a.active::after { + content: ""; + position: absolute; + left: 0; + right: 0; + bottom: -10px; + height: 3px; + background: var(--gd-orange); + border-radius: 999px; } -/* ========================================================================== - 5. RESPONSIVITÄT - ========================================================================== */ -@media (max-width: 1318px) { - .top-banner-bg { - height: 16.7vw; /* Hält das Seitenverhältnis */ - } - - .header-marquee { - left: 5%; /* Mehr Platz auf kleineren Screens */ - width: 90%; - } +.header-cta { + display: inline-flex; + align-items: center; + justify-content: center; + background: linear-gradient(135deg, #f06a2b 0%, #f6a443 100%); + color: white; + text-decoration: none; + font-weight: 800; + padding: 1rem 1.6rem; + border-radius: 999px; + box-shadow: 0 12px 25px rgba(241, 90, 36, 0.24); + white-space: nowrap; +} + +.landing-content { + margin-top: -24px; + position: relative; + z-index: 3; +} + +.media-card { + background: rgba(255,255,255,0.7); + border-radius: 28px; + overflow: hidden; + border: 1px solid rgba(255,255,255,0.28); + box-shadow: 0 18px 28px rgba(29, 17, 12, 0.11); + margin-bottom: 1.5rem; +} + +.media-thumb-wrap { + position: relative; + height: 250px; + overflow: hidden; +} + +.media-thumb-wrap img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.media-play { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; +} + +.media-play span { + width: 70px; + height: 70px; + border-radius: 50%; + background: rgba(241, 90, 36, 0.9); + display: block; + position: relative; + box-shadow: 0 16px 30px rgba(241, 90, 36, 0.38); +} + +.media-play span::before { + content: ""; + position: absolute; + left: 29px; + top: 22px; + width: 0; + height: 0; + border-top: 12px solid transparent; + border-bottom: 12px solid transparent; + border-left: 20px solid white; +} + +.media-meta { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + padding: 1rem 1.2rem 1.1rem; + background: rgba(255,255,255,0.72); +} + +.media-meta small { + display: block; + color: #7a675f; + font-size: 0.72rem; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.08em; +} + +.media-meta h3 { + margin: 0.35rem 0 0.2rem; + font-size: 1.05rem; + font-weight: 800; + color: #201614; +} + +.media-meta p { + margin: 0; + color: #71615d; + font-size: 0.85rem; +} + +.mini-play { + width: 42px; + height: 42px; + border: none; + border-radius: 50%; + background: #f4ece6; + color: var(--gd-orange); + font-size: 1rem; + cursor: pointer; +} + +.popular-panel { + background: rgba(255,255,255,0.7); + border: 1px solid rgba(255,255,255,0.4); + border-radius: 28px; + padding: 1.4rem 1.3rem 1rem; + box-shadow: 0 18px 28px rgba(29, 17, 12, 0.11); +} + +.popular-head { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 1rem; +} + +.popular-head h2 { + margin: 0; + font-size: clamp(2rem, 2.3vw, 2.6rem); + font-weight: 900; + color: #201614; +} + +.popular-head span { + padding: 0.5rem 0.8rem; + border-radius: 999px; + background: rgba(241, 90, 36, 0.08); + color: var(--gd-orange); + font-weight: 800; + font-size: 0.72rem; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.question-box { + background: white; + border-radius: 18px; + overflow: hidden; + margin-bottom: 1rem; + border: 1px solid rgba(244, 203, 181, 0.7); +} + +.question-tag { + background: linear-gradient(135deg, #f0672c 0%, #f4a749 100%); + color: white; + font-size: 0.7rem; + font-weight: 800; + text-transform: uppercase; + letter-spacing: 0.08em; + padding: 0.7rem 1rem; +} + +.question-body { + padding: 1rem 1rem 1.15rem; +} + +.question-body h4 { + margin: 0 0 0.5rem; + font-size: 1rem; + line-height: 1.4; + font-weight: 800; + color: #201614; +} + +.question-body p { + margin: 0; + color: #73615f; + line-height: 1.6; + font-size: 0.9rem; +} + +.popular-actions { + text-align: center; + margin-top: 1.4rem; +} + +.primary-btn { + border: none; + border-radius: 999px; + background: linear-gradient(135deg, #ef5d2b 0%, #f8b24d 100%); + color: white; + font-weight: 800; + text-transform: uppercase; + letter-spacing: 0.04em; + padding: 0.9rem 1.5rem; + box-shadow: 0 14px 24px rgba(239, 93, 43, 0.22); +} + +.promo-wrap { + margin-top: 2.6rem; +} + +.promo-box { + background: linear-gradient(135deg, #f15a24 0%, #ff9b2d 100%); + color: white; + border-radius: 32px; + padding: 2rem 1.4rem; + box-shadow: 0 20px 30px rgba(241, 90, 36, 0.22); +} + +.promo-label { + font-size: 1.2rem; + font-weight: 800; + margin-bottom: 1rem; +} + +.promo-question-col h3 { + margin: 0 0 1.4rem; + font-size: clamp(1.7rem, 2vw, 2.5rem); + line-height: 1.2; + font-weight: 800; +} + +.answer-grid { + display: grid; + grid-template-columns: repeat(2, minmax(140px, 1fr)); + gap: 0.8rem; +} + +.answer-btn { + border: none; + border-radius: 18px; + padding: 0.9rem 0.7rem; + background: rgba(255,255,255,0.9); + color: var(--gd-text); + font-weight: 800; + box-shadow: inset 0 -2px 0 rgba(0,0,0,0.06); +} + +.answer-btn.correct { + background: #fff7e8; + border: 2px solid rgba(255,255,255,0.8); +} + +.promo-image-col { + text-align: center; +} + +.promo-image-col img { + width: min(100%, 400px); + margin: 0 auto 1rem; + border-radius: 24px; + background: rgba(255,255,255,0.12); + padding: 1rem; +} + +.promo-image-col p { + margin: 0; + font-weight: 800; + opacity: 0.9; +} + +.stats-wrap { + margin-top: 2rem; + margin-bottom: 3rem; +} + +.stat-box { + background: rgba(255,255,255,0.72); + border-radius: 24px; + padding: 1.5rem 1rem; + text-align: center; + box-shadow: 0 12px 24px rgba(29,17,12,0.08); +} + +.stat-number { + font-size: clamp(2rem, 2vw, 2.8rem); + font-weight: 900; + color: #211714; + line-height: 1; +} + +.stat-label { + margin-top: 0.5rem; + font-size: 0.7rem; + letter-spacing: 0.12em; + text-transform: uppercase; + color: rgba(32,23,20,0.75); + font-weight: 800; +} + +@media (max-width: 1100px) { + .header-brand-wrap { + gap: 0.7rem; + } + + .header-nav { + gap: 1.1rem; + } } @media (max-width: 768px) { - .hero-section { - padding-bottom: 60px; - } - .btn-pill { - padding: 8px 20px !important; - } + .header-banner { + min-height: 270px; + } + + .header-brand-wrap { + flex-wrap: wrap; + justify-content: center; + padding-top: 12px; + } + + .brand-logo { + min-width: auto; + text-align: center; + padding-left: 0; + } + + .header-nav { + order: 3; + width: 100%; + justify-content: center; + gap: 1.2rem; + } + + .header-cta { + padding: 0.8rem 1rem; + font-size: 0.85rem; + } + + .landing-content { + margin-top: 0; + } + + .answer-grid { + grid-template-columns: 1fr; + } } \ No newline at end of file diff --git a/gd2/templates/gd2/home.html b/gd2/templates/gd2/home.html index 580149f..957c88a 100644 --- a/gd2/templates/gd2/home.html +++ b/gd2/templates/gd2/home.html @@ -1,186 +1,103 @@ {% extends 'gd2/base.html' %} +{% load static %} {% block content %} -
-
-
- -
- - +++ Willkommen bei Genial Daneben +++ Sende uns jetzt deine schrägste Frage ein! +++ Jeden Freitag / Samstag neue Folgen: 20:15 Uhr *** SAT1 +++ - -
- - - -
-
-
-

- Die Comedy-Quizshow
mit den schrägsten Fragen! -

-

- Schaltet ein und seht, ob das Panel
- die unglaublichsten Fragen beantworten kann. -

- -
+ - - -
+
-
-
-
- Show 1 -
-
-
-
+ {% for video in video_posts %} +
+
+ {{ video.titel }} +
+
-
+
- 19. Jan, 2023 -
Diether Krebs
-

Lustige Quizshows

-
-
-
+ {{ video.datum }} +

{{ video.titel }}

+

{{ video.kategorie }}

+
-
- -
-
- Show 2 -
-
-
-
-
-
-
-
- 12. Jan, 2023 -
Oliver Welke
-

Kuriose Raterunden

-
-
-
-
-
-
+
+ {% endfor %}
-
-

Beliebt

- -
-
- Resten Folgen -
-
-
Warum haben Kellner beim Weineinschenken die linke Hand auf dem Rücken?
-

weil früher den Weinsklaven in Rom die linke Hand auf den Rücken gebunden wurde, damit sie kein Gift ins Glas schütten konnten.

-
+
-
-
-
-
-

💡 Frage des Tages

-

Wie nennt man die Schuhe, die man durch Schnüren oder Binden verschließt?

-
-
-
-
-
+
+
+
+
+
💡 Frage des Tages
+

{{ daily_question.frage }}

+
+ {% for answer in daily_question.antworten %} + + {% endfor %}
-
- Team -

Noch mehr verrückte Fragen?

+
+ Genial Daneben Logo +

Noch mehr verrückte Fragen?

+ +
+
+ {% for stat in promo_stats %} +
+
+
{{ stat.value }}
+
{{ stat.label }}
+
+
+ {% endfor %} +
+
{% endblock %} \ No newline at end of file diff --git a/gd2/views.py b/gd2/views.py index 6425c09..b8408b3 100644 --- a/gd2/views.py +++ b/gd2/views.py @@ -1,37 +1,55 @@ from django.shortcuts import render + def home_view(request): - # Hier bereiten wir die Daten vor, die später aus der DB kommen könnten - # So bleibt dein Template sauber und dynamisch. - context = { 'video_posts': [ { 'datum': '19. Jan, 2023', 'titel': 'Diether Krebs', 'kategorie': 'Lustige Quizshows', - 'bild_url': 'https://via.placeholder.com/600x350' + 'bild_url': 'https://images.unsplash.com/photo-1507679799987-c73779587ccf?auto=format&fit=crop&w=900&q=80', }, { 'datum': '12. Jan, 2023', 'titel': 'Oliver Welke', 'kategorie': 'Kuriose Raterunden', - 'bild_url': 'https://via.placeholder.com/600x350' + 'bild_url': 'https://images.unsplash.com/photo-1522202176988-66273c2fd55f?auto=format&fit=crop&w=900&q=80', + }, + { + 'datum': '26. Dez, 2022', + 'titel': 'Die verrücktesten Fragen', + 'kategorie': 'Highlights', + 'bild_url': 'https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=900&q=80', }, ], 'top_fragen': [ { 'bereich': 'Beste Folgen', 'frage': 'Warum haben Kellner beim Weineinschenken die linke Hand auf dem Rücken?', - 'antwort_kurz': 'Weil früher den Weinsklaven in Rom die linke Hand...' + 'antwort_kurz': 'Weil früher den Weinsklaven in Rom die linke Hand auf den Rücken gebunden wurde, damit sie kein Gift ins Glas schütten konnten.', }, { 'bereich': 'Besten Fragen', 'frage': 'Warum nennt man die Toiletten auch "00"?', - 'antwort_kurz': 'Ein Hotelier hatte die Toiletten in seinem Hotel...' - } - ] + 'antwort_kurz': 'Ein Hotelier hatte die Toiletten in seinem Hotel durchnummeriert und vergab die Nummern nur für einzelne Räume. Daher blieb die erste Zahl als "00" übrig.', + }, + ], + 'daily_question': { + 'frage': 'Wie nennt man die Schuhe, die man durch Schnüren oder Binden verschließt?', + 'antworten': [ + 'Flip-Flops', + 'Mokassins', + 'Sandalen', + 'Schnürschuhe', + ], + 'correct_answer': 'Schnürschuhe', + }, + 'promo_stats': [ + {'label': 'Folgen', 'value': '120+'}, + {'label': 'Fragen', 'value': '8000+'}, + {'label': 'Panel', 'value': '24'}, + ], } - - # Wichtig: Pfad ist 'gd2/home.html', da home im Unterordner liegt + return render(request, 'gd2/home.html', context) \ No newline at end of file diff --git a/intern/templates/intern/analyse.html b/intern/templates/intern/analyse.html index 0985fd1..a5bb27f 100644 --- a/intern/templates/intern/analyse.html +++ b/intern/templates/intern/analyse.html @@ -31,6 +31,121 @@
+
+
+
+
+
Ø Panel
+
{{ stats.avg_panel_size }}
+
+
+
+
+
+
+
Ø Fragen/Folge
+
{{ stats.avg_fragen_pro_folge }}
+
+
+
+
+
+
+
YT Videos
+
{{ stats.yt_videos }}
+
+
+
+
+
+
+
Defekt
+
{{ stats.videos_mit_defekt }}
+
+
+
+
+
+
+
Ø Dauer
+
{{ stats.avg_dauer }}s
+
+
+
+
+
+
+
Top-Kategorien
+
{{ kategorien|length }}
+
+
+
+
+ +
+
+
+
📊 Team-Leistungsranking
+
+
+ + + + + + + + + + + + {% for team in team_stats %} + + + + + + + + {% empty %} + + {% endfor %} + +
PlatzNameAuftritteLösungenQuote
{{ forloop.counter }}{{ team.name }}{{ team.auftritte }}{{ team.loesungen }}{{ team.quote }}%
Keine Teamdaten vorhanden.
+
+
+
+
+ +
+
+
🏷️ Kategorien-Verteilung
+
+
+ + + + + + + + + {% for kat in kategorien %} + + + + + {% empty %} + + {% endfor %} + +
KategorieFragen
{{ kat.name }}{{ kat.fragen_count }}
Keine Kategorien hinterlegt.
+
+
+
+
+
+
diff --git a/intern/templates/intern/dashboard.html b/intern/templates/intern/dashboard.html index e170a33..09fe412 100644 --- a/intern/templates/intern/dashboard.html +++ b/intern/templates/intern/dashboard.html @@ -1,25 +1,286 @@ {% extends "intern/base.html" %} {% block content %}

Willkommen im GD-Backend

-

Archiv-Verwaltung

-
-
-
-

{{ total_folgen }}

-

Folgen insgesamt

+

Archiv-Verwaltung & Analyseübersicht

+ +
+
+
+
+
Folgen
+

{{ total_folgen }}

+
-
-
-

{{ total_fragen }}

-

Fragen im Archiv

+
+
+
+
Fragen
+

{{ total_fragen }}

+
-
-
-

{{ total_team }}

-

Teammitglieder/Gäste

+
+
+
+
Team
+

{{ total_team }}

+
+
+
+
+
+
+
Einsender
+

{{ total_einsender }}

+
+
+
+
+
+
+
Kategorien
+

{{ total_kategorien }}

+
+
+
+
+
+
+
YT
+

{{ total_yt_videos }}

+
+ +
+
+
+
+
Zuschauerfragen
+
{{ total_zuschauerfragen }}
+
+
+
+
+
+
+
Ohne Antwort
+
{{ total_ohne_antwort }}
+
+
+
+
+
+
+
Datenpunkte
+
{{ total_fragen }}
+
+
+
+
+
+
+
Archiv-Qualität
+
{{ total_folgen }}
+
+
+
+
+ +
+
+
+
Folgen pro Jahr
+
+ +
+
+
+
+
+
Fragenart
+
+ +
+
+
+
+ +
+
+
+
Fragen pro Jahr
+
+ +
+
+
+
+
+
Top-Kategorien
+
+ +
+
+
+
+ +
+
+
+
Top-Städte der Einsender
+
+ +
+
+
+
+
+
Top-Bundesländer
+
+ +
+
+
+
+ +
+
+
+
Top-Länder
+
+ +
+
+
+
+
+
Top-Auftritte der Teammitglieder
+
+ +
+
+
+
+ +
+
+
+
Top-Löser nach gelösten Fragen
+
+ +
+
+
+
+ +{{ data_folgen_pro_jahr|json_script:'folge-jahr-data' }} +{{ data_fragen_pro_jahr|json_script:'fragen-jahr-data' }} +{{ data_kategorien|json_script:'kategorie-data' }} +{{ data_staedte|json_script:'stadt-data' }} +{{ data_bundeslaender|json_script:'bundesland-data' }} +{{ data_laender|json_script:'land-data' }} +{{ data_team|json_script:'team-data' }} +{{ data_loeser|json_script:'loeser-data' }} +{{ data_fragen_verteilung|json_script:'fragen-art-data' }} + +{% block extra_js %} + + +{% endblock %} {% endblock %} \ No newline at end of file diff --git a/intern/templates/intern/folge_liste.html b/intern/templates/intern/folge_liste.html index f2326d0..1d6444f 100644 --- a/intern/templates/intern/folge_liste.html +++ b/intern/templates/intern/folge_liste.html @@ -56,7 +56,7 @@ {{ f.fragen_count }} {{ f.einsender_count }} - +
{% if f.zusatzinfo %} @@ -83,7 +83,7 @@ ✏️ - +
@@ -99,6 +99,9 @@
+
{% endfor %} diff --git a/intern/views.py b/intern/views.py index c4e3adc..27c8e92 100644 --- a/intern/views.py +++ b/intern/views.py @@ -1,8 +1,10 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required, user_passes_test -from django.db.models import Count, Q, Max +from django.db.models import Count, Q, Max, Avg from django.contrib import messages from django import forms +from django.core.serializers.json import DjangoJSONEncoder +import json from gd.models import Folge, Team, Frage, FolgePanel, FrageAntwort, FolgenZusatzInfo, Einsender, Kategorie from .forms import FolgeForm, FrageFormSet @@ -17,11 +19,112 @@ def is_admin(user): @login_required @user_passes_test(is_admin) def dashboard(request): + echte_team_filter = ~Q(name__icontains='unbekannt') & ~Q(name__icontains='Hugo Egon Balder') + + folgen_pro_jahr = list( + Folge.objects.values('datum__year').annotate(count=Count('id')).order_by('datum__year') + ) + folgen_pro_jahr_labels = [str(item['datum__year']) for item in folgen_pro_jahr] + folgen_pro_jahr_values = [int(item['count']) for item in folgen_pro_jahr] + + fragen_pro_jahr = list( + Frage.objects.values('folge__datum__year').annotate(count=Count('id')).order_by('folge__datum__year') + ) + fragen_pro_jahr_labels = [str(item['folge__datum__year']) for item in fragen_pro_jahr] + fragen_pro_jahr_values = [int(item['count']) for item in fragen_pro_jahr] + + kategorien = list( + Kategorie.objects.annotate(question_count=Count('fragen')).filter(question_count__gt=0).order_by('-question_count')[:8] + ) + kategorie_labels = [k.name for k in kategorien] + kategorie_values = [int(k.fragen.count()) for k in kategorien] + + top_staedte = list( + Einsender.objects.exclude(stadt__isnull=True).exclude(stadt='').values('stadt').annotate(count=Count('fragen')).order_by('-count')[:8] + ) + stadt_labels = [item['stadt'] for item in top_staedte] + stadt_values = [int(item['count']) for item in top_staedte] + + top_bundeslaender = list( + Einsender.objects.exclude(bundesland__isnull=True).exclude(bundesland='').values('bundesland').annotate(count=Count('fragen')).order_by('-count')[:8] + ) + bundesland_labels = [item['bundesland'] for item in top_bundeslaender] + bundesland_values = [int(item['count']) for item in top_bundeslaender] + + top_laender = list( + Einsender.objects.exclude(land__isnull=True).exclude(land='').values('land').annotate(count=Count('fragen')).order_by('-count')[:8] + ) + land_labels = [item['land'] for item in top_laender] + land_values = [int(item['count']) for item in top_laender] + + top_team = list( + Team.objects.filter(echte_team_filter).annotate(auftritte=Count('folgepanel', distinct=True), loesungen=Count('frageantwort', distinct=True)).order_by('-auftritte', '-loesungen')[:8] + ) + team_labels = [team.name for team in top_team] + team_values = [int(team.auftritte) for team in top_team] + + top_loeser = list( + Team.objects.filter(echte_team_filter).annotate(loesungen=Count('frageantwort', distinct=True)).order_by('-loesungen')[:8] + ) + loeser_labels = [team.name for team in top_loeser] + loeser_values = [int(team.loesungen) for team in top_loeser] + + zuschauerfrage_verteilung = list( + Frage.objects.values('zuschauer_frage').annotate(count=Count('id')) + ) + fragen_verteilung_labels = ['Zuschauerfrage', 'Archiv-Frage'] + fragen_verteilung_values = [ + next((item['count'] for item in zuschauerfrage_verteilung if item['zuschauer_frage'] is True), 0), + next((item['count'] for item in zuschauerfrage_verteilung if item['zuschauer_frage'] is False), 0), + ] + context = { 'total_folgen': Folge.objects.count(), 'total_fragen': Frage.objects.count(), - 'total_team': Team.objects.count(), + 'total_team': Team.objects.filter(echte_team_filter).count(), + 'total_einsender': Einsender.objects.count(), + 'total_kategorien': Kategorie.objects.count(), + 'total_yt_videos': FolgenZusatzInfo.objects.exclude(yt_adresse__isnull=True).exclude(yt_adresse='').count(), + 'total_zuschauerfragen': Frage.objects.filter(zuschauer_frage=True).count(), + 'total_ohne_antwort': Frage.objects.filter(antwort__isnull=True).count(), + 'data_folgen_pro_jahr': { + 'labels': folgen_pro_jahr_labels, + 'values': folgen_pro_jahr_values, + }, + 'data_fragen_pro_jahr': { + 'labels': fragen_pro_jahr_labels, + 'values': fragen_pro_jahr_values, + }, + 'data_kategorien': { + 'labels': kategorie_labels, + 'values': kategorie_values, + }, + 'data_staedte': { + 'labels': stadt_labels, + 'values': stadt_values, + }, + 'data_bundeslaender': { + 'labels': bundesland_labels, + 'values': bundesland_values, + }, + 'data_laender': { + 'labels': land_labels, + 'values': land_values, + }, + 'data_team': { + 'labels': team_labels, + 'values': team_values, + }, + 'data_loeser': { + 'labels': loeser_labels, + 'values': loeser_values, + }, + 'data_fragen_verteilung': { + 'labels': fragen_verteilung_labels, + 'values': fragen_verteilung_values, + }, } + return render(request, 'intern/dashboard.html', context) # --- FOLGEN MANAGEMENT --- @@ -347,7 +450,7 @@ def kategorie_sort(request, pk, direction): def analyse(request): # 1. Fragen ohne Antwort fragen_ohne_antwort = Frage.objects.filter(antwort__isnull=True) - + # 2. Fragen mit Löser "unbekannt" fragen_mit_unbekannt = Frage.objects.filter( antwort__team__name__icontains="unbekannt" @@ -369,16 +472,12 @@ def analyse(request): ).filter(fragen_count__lt=4).order_by('-folgen_nummer') # --- Statistik & Gäste-Checks --- - - # Filter für echte Gäste (schließt Platzhalter und Moderator aus) echte_gaeste_filter = ~Q(name__icontains="unbekannt") & ~Q(name__icontains="Hugo Egon Balder") - # Top Gäste (nur echte) top_gaeste = Team.objects.filter(echte_gaeste_filter).annotate( auftritte=Count('folgepanel') ).order_by('-auftritte')[:5] - # KORREKTUR: Gäste ohne Einsatz (nur echte Personen berücksichtigen) gaeste_ohne_einsatz = Team.objects.filter(echte_gaeste_filter).annotate( einsaetze=Count('folgepanel') ).filter(einsaetze=0).order_by('name') @@ -388,7 +487,6 @@ def analyse(request): fragen_count=Count('fragen') ).order_by('-fragen_count')[:10] - # Bundesländer ohne leere Werte (keine Angabe entfernen) top_bundeslaender = Einsender.objects.exclude(bundesland__isnull=True).exclude(bundesland__exact='').values('bundesland').annotate( fragen_count=Count('fragen') ).order_by('-fragen_count')[:10] @@ -397,6 +495,41 @@ def analyse(request): fragen_count=Count('fragen') ).order_by('-fragen_count')[:10] + # Zusatz-Analysen für die Detail-Ansicht + folge_qualitaet = Folge.objects.annotate( + panel_count=Count('panel', distinct=True), + fragen_count=Count('fragen', distinct=True) + ).order_by('-folgen_nummer') + + panel_auslastung = list(folge_qualitaet.values_list('panel_count', 'fragen_count')) + avg_panel_size = round(sum(panel for panel, _ in panel_auslastung) / len(panel_auslastung), 2) if panel_auslastung else 0 + avg_fragen_pro_folge = round(sum(fragen for _, fragen in panel_auslastung) / len(panel_auslastung), 2) if panel_auslastung else 0 + + yt_videos = FolgenZusatzInfo.objects.exclude(yt_adresse__isnull=True).exclude(yt_adresse='').count() + videos_mit_defekt = FolgenZusatzInfo.objects.filter(video_defekt_gemeldet=True).count() + + kategorien = Kategorie.objects.annotate( + fragen_count=Count('fragen') + ).order_by('-fragen_count')[:10] + + avg_dauer = Frage.objects.exclude(dauer_sekunden__isnull=True).aggregate(avg_dauer=Avg('dauer_sekunden'))['avg_dauer'] + avg_dauer = round(avg_dauer, 1) if avg_dauer else 0 + + top_team_stats = [] + for team in Team.objects.filter(echte_gaeste_filter).annotate( + auftritte=Count('folgepanel', distinct=True), + loesungen=Count('frageantwort', distinct=True) + ).order_by('-loesungen', '-auftritte')[:8]: + folgen_ids = team.folgepanel_set.values_list('folge_id', flat=True) + fragen_moeglich = Frage.objects.filter(folge_id__in=folgen_ids).count() if folgen_ids else 0 + quote = round((team.loesungen / fragen_moeglich) * 100, 1) if fragen_moeglich else 0 + top_team_stats.append({ + 'name': team.name, + 'auftritte': team.auftritte, + 'loesungen': team.loesungen, + 'quote': quote, + }) + stats = { 'gesamt_folgen': Folge.objects.count(), 'gesamt_fragen': Frage.objects.count(), @@ -409,12 +542,17 @@ def analyse(request): fragen_mit_unbekannt.count() + folgen_ohne_zuschauerfrage.count() ), + 'avg_panel_size': avg_panel_size, + 'avg_fragen_pro_folge': avg_fragen_pro_folge, + 'yt_videos': yt_videos, + 'videos_mit_defekt': videos_mit_defekt, + 'avg_dauer': avg_dauer, } return render(request, 'intern/analyse.html', { 'fragen_ohne_antwort': fragen_ohne_antwort, 'fragen_mit_unbekannt': fragen_mit_unbekannt, - 'folgen_ohne_zuschauerfrage': folgen_ohne_zuschauerfrage, # Variable angepasst + 'folgen_ohne_zuschauerfrage': folgen_ohne_zuschauerfrage, 'luecken_panel': luecken_panel, 'luecken_fragen': luecken_fragen, 'top_gaeste': top_gaeste, @@ -422,5 +560,7 @@ def analyse(request): 'top_staedte': top_staedte, 'top_bundeslaender': top_bundeslaender, 'top_laender': top_laender, - 'stats': stats + 'kategorien': kategorien, + 'team_stats': top_team_stats, + 'stats': stats, }) \ No newline at end of file