{% load danceschool_tags i18n %}

{% if regClosedSeries %}
	<h2>{% trans "Ongoing Series (Registration Closed)" %}</h2>
	<hr />
{% regroup regClosedSeries|dictsort:"month" by month as open_list %}
	{% for month in open_list %}
	<div class="classmonth">
        <h3>{{ month.grouper|readable_month }} {% trans "Class Series" %}</h3>
		<div class="table serieslist">
		{% regroup month.list|dictsort:"weekday" by weekday as weekday_list %}
			{% for weekday in weekday_list %}
				<div class="weekdaygroup">
				<div class="weekday">
					<div><h3>{% readable_weekday weekday.grouper %}s</h3></div>
				</div>
				<div class="weekdaycontents">
					{% for event in weekday.list %}


					<a name="{{ event.slug }}"></a>
                    <table class="series" id="eventtable_{{ event.id}}">
                        <tr>
                            <th class="time">
								<h4>{{ event.startTime|date:"g:i A" }} - <br />
								{{ event.endTime|date:"g:i A" }} </h4>
							</th>
                            <td class="info">
                                <h3 class="title">{{ event.name }}</h3>
                                <h4>
								{% if event.teachers %}
									{% trans "with" %} {{ event.teachers|join:" &amp; "}}
								{% endif %}

								at
									{% if directions_url %}
									<a href = "{{ directions_url }}#{{ event.location.name|slugify }}">
										{{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
									</a>
									{% else %}
										{{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
									{% endif %}

                                    {% if event.url %}<small><a href="{{ event.url }}">{% trans "more info" %}</a></small>{% endif %}
                                </h4>
                                <div class="dates">
								{% for occurrence in event.eventoccurrence_set.all %}
									{{ occurrence.startTime|date:"N j"}}{% if not forloop.last %}, {% endif %}
								{% endfor %}
								</div>
                                <div class="leadfollow">
                                    <div class="leadfollow-options">
                                    	<ul>
                                    	{% for role in event.availableRoles %}
											<li>{{ role.pluralName }} ({% numRegisteredForRole event role  %} {% trans "registered" %})</li>
										{% empty %}
											<li>({{ event.numRegistered }} {% trans "registered" %})</li>
										{% endfor %}
										</ul>
                                        {% if perms.core.override_register_closed %}
											{% get_field_for_object 'event' event.id form as field %}
                                        	{{ field }}
		                                    {% if validationStr %}
											<div colspan="2" class="checkboxvalidation">
												{{ field.errors }}
											</div>
		                                    {% endif %}
	                                    {% endif %}
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
					{% endfor %}
				</div>
				</div>
			{% endfor %}
		</div>
	</div>
	{% endfor %}
{% endif %}
