Luke Plant committed dc1901d

Corrected stats on booking report page

Comments (0)

Files changed (3)


     ### Main business rules here ###
+    def is_booked(self):
+        return self.state == BOOKING_BOOKED
+    @property
     def is_confirmed(self):
-        return self.state == BOOKING_BOOKED and self.booking_expires is None
+        return self.is_booked and self.booking_expires is None
     def expected_amount_due(self):
         if self.price_type == PRICE_CUSTOM:


     camps = Camp.objects.filter(year=year).prefetch_related('bookings')
     # Do some filtering in Python to avoid multiple db hits
     for c in camps:
-        c.confirmed_bookings = [b for b in c.bookings.all() if b.is_confirmed]
+        c.booked_places = [b for b in c.bookings.booked()]
+        c.confirmed_bookings = [b for b in c.booked_places if b.is_confirmed]
         c.confirmed_bookings_boys = [b for b in c.confirmed_bookings if == SEX_MALE]
         c.confirmed_bookings_girls = [b for b in c.confirmed_bookings if == SEX_FEMALE]


 {% for camp in camps %}
     <td>{{ camp }}</td>
-    <td>{{ camp.bookings.all|length }}</td>
+    <td>{{ camp.booked_places|length }}</td>
     <td>{{ camp.confirmed_bookings|length }}</td>
     <td>{{ camp.confirmed_bookings_boys|length }}</td>
     <td>{{ camp.confirmed_bookings_girls|length }}</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
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.