Commits

Luke Plant  committed 8bc342f

On 'add place' page, decorated 'Price' dropdown labels with actual current price

  • Participants
  • Parent commits e9b8906
  • Branches bookings

Comments (0)

Files changed (1)

File cciw/bookings/forms.py

+# -*- coding: utf-8 -*-
 from django import forms
 from django.utils.html import escape
 from django.utils.safestring import mark_safe
 
-from cciw.bookings.models import BookingAccount, Booking
+from cciw.bookings.models import BookingAccount, Booking, Price
 from cciw.cciwmain.forms import CciwFormMixin
 from cciw.cciwmain.common import get_thisyear
 from cciw.cciwmain.models import Camp
                            c.get_places_left()) + '</span>')
         self.fields['camp'].choices = [(c.id, mark_safe(render_camp(c)))
                                        for c in Camp.objects.filter(year=get_thisyear())]
+        price_choices = self.fields['price_type'].choices
+        prices = dict((p.price_type, p.price) for p in Price.objects.filter(year=get_thisyear()))
+
+        for i, (price_type, label) in enumerate(price_choices):
+            if price_type in prices:
+                price_choices[i] = (price_choices[i][0], price_choices[i][1] + " - £%s" % prices[price_type])
+        self.fields['price_type'].choices = price_choices
 
 
     class Meta: