fix
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Apr 2026 14:01:24 +0000 (16:01 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Apr 2026 14:01:24 +0000 (16:01 +0200)
src/club/templates/club/stats.html
src/club/views.py

index 2bdf6ec..a1ccb5a 100644 (file)
@@ -3,22 +3,31 @@
 {% block main %}
 
 
 {% block main %}
 
 
-<table style="width: 100%;">
+<table style="" border="1">
   <thead>
     <tr>
   <thead>
     <tr>
-      <th></th>
-      <th>PayU</th>
-      <th>PayU cykliczne</th>
-      <th>PayPal</th>
+      <th style="width: 200px;"></th>
+      <th style="width: 200px;">PayU</th>
+      <th style="width: 200px;">PayU cykliczne</th>
+      <th style="width: 200px;">PayPal</th>
     </tr>
   </thead>
   <tbody>
   {% for day, acq in days %}
   <tr>
     <td>{{ day }}</td>
     </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>
+    <td style="position: relative">
+      <span style="z-index: 0; background: #92BD39; position: absolute;left:0; top:0; bottom: 0; width: {{ acq.payu.1 }}%;"></span>
+      <span style="z-index: 1; position: relative;">{{ acq.payu.0 }}</span>
+    </td>
+    <td style="position: relative">
+      <span style="z-index: 0; background: #92BD39; position: absolute;left:0; top:0; bottom: 0; width: {{ acq.payu_re.1 }}%;"></span>
+      <span style="z-index: 1; position: relative;">{{ acq.payu_re.0 }}</span>
+    </td>
+    <td style="position: relative">
+      <span style="z-index: 0; background: #92BD39; position: absolute;left:0; top:0; bottom: 0; width: {{ acq.paypal.1 }}%;"></span>
+      <span style="z-index: 1; position: relative;">{{ acq.paypal.0 }}</span>
+    </td>
   </tr>
   {% endfor %}
   </tbody>
   </tr>
   {% endfor %}
   </tbody>
index 177989e..3f283af 100644 (file)
@@ -289,6 +289,7 @@ def receipt(request):
 
 @permission_required('club.schedule_view')
 def stats(request):
 
 @permission_required('club.schedule_view')
 def stats(request):
+    maxes = {}
     acq = {}
     today = date.today()
     start = today - timedelta(365)
     acq = {}
     today = date.today()
     start = today - timedelta(365)
@@ -300,11 +301,20 @@ def stats(request):
         acq.setdefault(d, {})
         acq[d].setdefault(m, 0)
         acq[d][m] += schedule.amount
         acq.setdefault(d, {})
         acq[d].setdefault(m, 0)
         acq[d][m] += schedule.amount
-        
+
+    for a in acq.values():
+        for m, v in a.items():
+            maxes.setdefault(m, 0)
+            if v > maxes[m]:
+                maxes[m] = v
+
     days = []
     d = today
     while d >= start:
     days = []
     d = today
     while d >= start:
-        days.append((d.isoformat(), acq.get(d, {})))
+        a = acq.get(d, {})
+        for k, v in a.items():
+            a[k] = (v, 100 * v/(maxes[k] or 1))
+        days.append((d.isoformat(), a))
         d -= timedelta(1)
 
     return render(request, 'club/stats.html',
         d -= timedelta(1)
 
     return render(request, 'club/stats.html',