Commits

Luke Plant committed 8551962

Improved admin interface for Booking

  • Participants
  • Parent commits 21fcce5
  • Branches bookings

Comments (0)

Files changed (2)

File cciw/bookings/admin.py

     def camp(obj):
         return "%s-%s" % (obj.camp.year, obj.camp.number)
     camp.admin_order_field = 'camp__year'
-    list_display = ['name', 'sex', 'account', camp, 'state']
+    list_display = ['name', 'sex', 'account', camp, 'state', 'confirmed_booking']
     del camp
     search_fields = ['name']
     ordering = ['-camp__year', 'camp__number']
     date_hierarchy = 'created'
-    list_filter = [YearFilter, 'sex', 'price_type', 'serious_illness', 'south_wales_transport']
+    list_filter = [YearFilter, 'sex', 'price_type', 'serious_illness', 'south_wales_transport',
+                   'state']
 
 
 admin.site.register(Price, PriceAdmin)

File cciw/bookings/models.py

 
 from dateutil.relativedelta import relativedelta
 from django.db import models
+from django.utils.safestring import mark_safe
 
 from cciw.cciwmain.common import get_thisyear
 from cciw.cciwmain.models import Camp
     shelved = models.BooleanField(default=False)
 
     # State - internal
-    state = models.IntegerField(choices=BOOKING_STATES)
+    state = models.IntegerField(choices=BOOKING_STATES,
+                                help_text=mark_safe(
+            "<ul><li>Move to 'Manually approved' to allow user to book and pay</li>"
+            "<li>To book, move to 'Booked' <b>and</b> ensure 'Booking expires' is empty</li>"
+            "</ul>"))
+
     created = models.DateTimeField(default=datetime.now)
     booking_expires = models.DateTimeField(null=True, blank=True)
 
 
     ### Main business rules here ###
 
+    def confirmed_booking(self):
+        return self.state == BOOKING_BOOKED and self.booking_expires is None
+    confirmed_booking.boolean = True
+
     def auto_set_amount_due(self):
         if self.price_type == PRICE_CUSTOM:
             if self.amount_due is None: