Luke Plant avatar Luke Plant committed 6723ab5

Presentation tweak to 'booking secretary report page' to add rowspans to certain rows

Comments (0)

Files changed (2)

cciw/officers/views.py

+from collections import defaultdict
 import datetime
 import operator
 import urlparse
     bookings = Booking.objects.filter(camp__year__exact=year,
                                       account__in=[o.id for o in outstanding])
     bookings = bookings.order_by('account__name','first_name','last_name')
-    # Decorate with the already calculated 'total_amount_due'
+
+    # Decorate with the already calculated 'total_amount_due', and with 'number
+    # of bookings for this account'
+    counts = defaultdict(int)
+    for b in bookings:
+        counts[b.account_id] += 1
+
     for b in bookings:
         b.account.calculated_balance = total_amount_due_dict[b.account_id] - b.account.total_received
+        b.count_for_account = counts[b.account_id]
 
     return render(request, 'cciw/officers/booking_secretary_reports.html',
                   {'year': year, 'camps': camps,

templates/cciw/officers/booking_secretary_reports.html

   {% for b in bookings %}
   <tr>
     {% ifchanged b.account.id %}
-    <td>{{ b.account.name }}</td>
-    <td>{{ b.account.email }}</td>
-    <td>{{ b.account.phone_number }}</td>
-    <td>{{ b.account.calculated_balance }}</td>
-    {% else %}
-    <td colspan=4></td>
+    <td rowspan="{{ b.count_for_account }}">{{ b.account.name }}</td>
+    <td rowspan="{{ b.count_for_account }}">{{ b.account.email }}</td>
+    <td rowspan="{{ b.count_for_account }}">{{ b.account.phone_number }}</td>
+    <td rowspan="{{ b.count_for_account }}">{{ b.account.calculated_balance }}</td>
     {% endifchanged %}
     <td>{{ b.name }}</td>
     <td>{{ b.camp.number }}</td>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.