def __str__(self):
return "Webclass slot : " + str(self.id)
+ @property
+ def date(self):
+ """
+ Compute the last date (from weekday) before the end of webclass.
+ This is the webclass date. Before, webclass were every "monday" for example.
+ Now there is only one date per webclass.
+ This is not ideal. We should have a "date" field on the webclass slot instead of "day".
+ But we're waiting to see how PB use webclasses in the future.
+ """
+ end_day = self.webclass.end_date
+ next_day = end_day + datetime.timedelta(days=7 - end_day.weekday() + self.day, weeks=-1)
+ if next_day > end_day:
+ next_day = next_day - datetime.timedelta(weeks=1)
+ return next_day
+
@property
def remaining_participant_slot(self):
"""
{% for slot in slots %}
<tr>
<td>
- <span class="booking_date"><strong>{{slot.get_day_display}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à <strong>{{slot.end_hour|date:"H\hi"}}</strong></span>
+ <span class="booking_date">{{slot.get_day_display}} <strong>{{slot.date}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à <strong>{{slot.end_hour|date:"H\hi"}}</strong></span>
</td>
<td>
{{slot.professor}}
<td>
<form class="booking_form" method="POST">
- <span class="booking_date" style="display:none"><strong>{{slot.get_day_display}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à <strong>{{slot.end_hour|date:"H\hi"}}</strong></span>
+ <span class="booking_date" style="display:none">{{slot.get_day_display}} <strong>{{slot.date}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à <strong>{{slot.end_hour|date:"H\hi"}}</strong></span>
{% csrf_token %}
<input type="hidden" name="slot_id" value="{{slot.id}}" />
{% if slot.participant_slot_available %}
{% for slot in slots %}
<tr>
<td>
- <span><strong>{{slot.get_day_display}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à
+ <span>{{slot.get_day_display}} <strong>{{slot.date}}</strong> de <strong>{{slot.start_hour|date:"H\hi"}}</strong> à
<strong>{{slot.end_hour|date:"H\hi"}}</strong></span>
</td>
<td>
{% if webclass_slot %}
<tr>
<td colspan="2">
- <p>Vous êtes inscrit pour les webclasses du
- <strong>{{webclass_slot.get_day_display}} de
+ <p>Vous êtes inscrit pour la webclass du
+ <strong>{{webclass_slot.get_day_display}} {{webclass_slot.date}} de
{{webclass_slot.start_hour|date:"H\hi"}} à
{{webclass_slot.end_hour|date:"H\hi"}}</strong>
avec le professeur <strong>{{webclass_slot.professor.user.last_name}}</strong>.