stats
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Apr 2026 13:46:41 +0000 (15:46 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Apr 2026 13:46:41 +0000 (15:46 +0200)
src/club/templates/club/stats.html [new file with mode: 0644]
src/club/urls.py
src/club/views.py

diff --git a/src/club/templates/club/stats.html b/src/club/templates/club/stats.html
new file mode 100644 (file)
index 0000000..2bdf6ec
--- /dev/null
@@ -0,0 +1,27 @@
+{% extends "base.html" %}
+
+{% block main %}
+
+
+<table style="width: 100%;">
+  <thead>
+    <tr>
+      <th></th>
+      <th>PayU</th>
+      <th>PayU cykliczne</th>
+      <th>PayPal</th>
+    </tr>
+  </thead>
+  <tbody>
+  {% for day, acq in days %}
+  <tr>
+    <td>{{ day }}</td>
+    <td>{{ acq.payu }}</td>
+    <td>{{ acq.payu_re }}</td>
+    <td>{{ acq.paypal }}</td>
+  </tr>
+  {% endfor %}
+  </tbody>
+</table>
+
+{% endblock %}
index c7bab6a..95c51e0 100644 (file)
@@ -31,4 +31,5 @@ urlpatterns = [
     path('weryfikacja/', views.member_verify, name='club_member_verify'),
 
     path('potwierdzenie/', views.receipt, name='club_receipt'),
     path('weryfikacja/', views.member_verify, name='club_member_verify'),
 
     path('potwierdzenie/', views.receipt, name='club_receipt'),
+    path('stats/', views.stats),
 ]
 ]
index 503a431..177989e 100644 (file)
@@ -1,6 +1,7 @@
 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
 #
 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
 #
+from datetime import date, timedelta
 from django.conf import settings
 from django.contrib.auth.decorators import login_required, permission_required
 from django.db.models import Sum
 from django.conf import settings
 from django.contrib.auth.decorators import login_required, permission_required
 from django.db.models import Sum
@@ -285,3 +286,27 @@ def receipt(request):
         }
     )
 
         }
     )
 
+
+@permission_required('club.schedule_view')
+def stats(request):
+    acq = {}
+    today = date.today()
+    start = today - timedelta(365)
+    for schedule in models.Schedule.objects.filter(
+        payed_at__gte=start,
+    ):
+        d = schedule.payed_at.date()
+        m = schedule.method.replace('-', '_')
+        acq.setdefault(d, {})
+        acq[d].setdefault(m, 0)
+        acq[d][m] += schedule.amount
+        
+    days = []
+    d = today
+    while d >= start:
+        days.append((d.isoformat(), acq.get(d, {})))
+        d -= timedelta(1)
+
+    return render(request, 'club/stats.html',
+                  {'days': days})
+