Commits

Luke Plant committed 9159ada

Added 'book now' button to camp detail page

Comments (0)

Files changed (2)

cciw/cciwmain/models.py

                 max(self.max_male_campers - males_booked, 0),
                 max(self.max_female_campers - females_booked, 0))
 
+    def is_booking_open(self):
+        from cciw.bookings.views import is_booking_open
+        return is_booking_open(self.year)
+
     class Meta:
         ordering = ['-year','number']
         unique_together = (('year', 'number'),)

templates/cciw/camps/detail.html

 {% extends "cciw/standard.html" %}
+{% load url from future %}
+
 {% block content %}
 	<br/>
 {% if camp.is_past %}
 			</ul>
 		</td>
 	</tr>
+        {% if camp.year == thisyear and camp.is_booking_open %}
+        <tr>
+               <th scope="row">Places:</th>
+               <td>
+                 {% with total=camp.get_places_left.0 %}
+                 {% if total > 0 %}
+                     {{ total }} places still available:<br/><br/> <a class="booknow" href="{% url 'cciw.bookings.views.start' %}">Book online now!</a><br/><br/>
+                     <a href="{% url 'cciw.bookings.views.index' %}">See other booking options and prices</a>
+                 {% else %}
+                     No more places available on this camp, sorry.
+                 {% endif %}
+                 {% endwith %}
+               </td>
+        </tr>
+        {% endif %}
 </table>
 {% endblock %}