Luke Plant avatar Luke Plant committed a24bdf5

Added cancelled bookings to account overview page

Comments (0)

Files changed (4)

cciw/bookings/models.py

         cancelled = self.get_query_set().filter(state=BOOKING_CANCELLED)
         return cancelled | (self.confirmed() if confirmed_only else self.booked())
 
+    def cancelled(self):
+        return self.get_query_set().filter(state=BOOKING_CANCELLED)
+
 
 class Booking(models.Model):
     account = models.ForeignKey(BookingAccount, related_name='bookings')

cciw/bookings/tests.py

         # 3rd place, not booked at all
         self.create_place({'name': '3rd child'})
 
+        # 4th place, cancelled
+        self.create_place({'name': '4th child'})
+        b = acc.bookings.get(name='4th child')
+        b.state = BOOKING_CANCELLED
+        b.auto_set_amount_due()
+        b.save()
+
         resp = self.client.get(self.url)
 
         # Another one, so that messages are cleared
         # Basket/Shelf
         self.assertContains(resp, 'items in your basket')
 
+        # Deposit for cancellation
+        self.assertContains(resp, u"Cancelled")
+        self.assertContains(resp, u"(£20 deposit)")
+
 
 class TestLogOut(LogInMixin, TestCase):
 

cciw/bookings/views.py

         year = get_thisyear()
         c['confirmed_places'] = acc.bookings.confirmed().filter(camp__year__exact=year)
         c['unconfirmed_places'] = acc.bookings.unconfirmed().filter(camp__year__exact=year)
+        c['cancelled_places'] = acc.bookings.cancelled().filter(camp__year__exact=year)
         c['basket'] = acc.bookings.basket(year).exists()
         c['shelf'] = acc.bookings.shelf(year).exists()
         return c

templates/cciw/bookings/account_overview.html

 <p>You have no confirmed places yet.</p>
 {% endif %}
 
+{% if cancelled_places %}
+<h2>Cancelled places</h2>
+
+<ul>
+{% for b in cancelled_places %}
+  <li>{{ b.name }}, on <a href="{% url 'cciw.cciwmain.views.camps.detail' year=b.camp.year number=b.camp.number %}">camp {{ b.camp.number }}</a> (£{{ b.amount_due }} deposit)</li>
+{% endfor %}
+</ul>
+{% endif %}
 
 {% endblock %}
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.