{% extends "cms/home.html" %}
{% load cms_tags danceschool_tags sekizai_tags static i18n %}

{% block content %}

{% page_url 'directions' as directions_url %}
{% page_url 'calendar' as calendar_url %}

<div class="row">

{# Display any warning or error messages associated with the previous form submission #}
<div id="message-alerts">
{% for message in messages %}
    <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger{% elif message.level == DEFAULT_MESSAGE_LEVELS.WARNING %}alert-warning{% else %}alert-info{% endif %}">{{ message }}</div>
{% endfor %}
</div>

<div class="col-md-12 top-col">
	{% block top %}
		{% static_placeholder 'registration_top' %}
	{% endblock %}
</div>

<div class="col-md-12 content-col">

{% block coming_soon %}
	{% if not allSeries and not allEvents %}
		<h2>{% trans "More Classes and Events Coming Soon!" %}</h2>
		<p>{% blocktrans %}Our upcoming classes have not yet been posted, but don't worry, they will be posted here soon!  Check back soon for more information.{% endblocktrans %}</p>
		{% if calendar_url %}<p>{% blocktrans %}In the meantime, check out our <a href="{{ calendar_url }}">calendar</a> for more information about our past and current classes.</p>{% endblocktrans %}{% endif %}
	{% elif not allSeries %}
		<h2>{% trans "More Classes Coming Soon!" %}</h2>
		<p>{% blocktrans %}Our upcoming classes have not yet been posted, but don't worry, they will be posted here soon!  Check back soon for more information.{% endblocktrans %}</p>
		{% if calendar_url %}<p>{% blocktrans %}In the meantime, check out our <a href="{{ calendar_url }}">calendar</a> for more information about our past and current classes.</p>{% endblocktrans %}{% endif %}
	{% endif %}
{% endblock %}

{% if allSeries or allEvents %}

{% block registration_form %}
<form id="classregform" name="input" action="" method="post">
    {% csrf_token %}
    {{ form.voucher_id }}

    {% block door_reg %}
	    {% if perms.core.accept_door_payments %}
	    <div class="alert alert-info" role="alert">
		    <h4>{% trans "Is this a door/invoice registration?" %}<br />
		    <small>({% trans "to be filled out only by school staff" %})</small>
		    </h4>
		    <p>{% trans "This is a door/invoice registration" %} {{ form.payAtDoor }}</p>
	    </div>
	    {% endif %}
    {% endblock %}
    
    <div id="classes">
        <div id="validation">
            {{ form.non_field_errors }}
        </div>

        {# List of Category-separated Series #}
        {% block category_separate_series %}
        	{% regroup categorySeparateSeries by category as category_separated_list %}

        	{% for category_list in category_separated_list %}
        		{% if "core/registration/series_category_"|add:category_list.grouper.slug|add:".html"|template_exists %}
        			{% include "core/registration/series_category_"|add:category_list.grouper.slug|add:".html" %}
        		{% else %}
        			{% include "core/registration/series_category__default.html" %}
        		{% endif %}
        	{% endfor %}
		{% endblock %}

        {# List of Class Series with Open Registration #}
        {% block reg_open_series %}
        	{% include "core/registration/reg_open_series.html" %}
		{% endblock %}

		{# List of Category-separated Public Events #}
		{% block category_separate_events %}
        	{% regroup categorySeparateEvents by category as category_separated_list %}

        	{% for category_list in category_separated_list %}
        		{% if "core/registration/event_category_"|add:category_list.grouper.slug|add:".html"|template_exists %}
        			{% include "core/registration/event_category_"|add:category_list.grouper.slug|add:".html" %}
        		{% else %}
        			{% include "core/registration/event_category__default.html" %}
        		{% endif %}
        	{% endfor %}
		{% endblock %}

        {# List of Upcoming Public Events with Open Registration #}
        {% block reg_open_events %}
        	{% include "core/registration/reg_open_events.html" %}
		{% endblock %}

        {# List of Upcoming Public Events without/with closed Registration #}
        {% block reg_closed_events %}
        	{% include "core/registration/reg_closed_events.html" %}
		{% endblock %}

        {# List of Ongoing Class Series with closed Registration #}
        {% block reg_closed_series %}
        	{% include "core/registration/reg_closed_series.html" %}
		{% endblock %}

    </div>
</form>
{% endblock %}

</div>
</div>

{% block content_js %}
	{% addtoblock "js" %}
	<script type="text/javascript" src="{% static 'ekko-lightbox/ekko-lightbox.min.js' %}"></script>
	<script type="text/javascript">
	$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
	    event.preventDefault();
	    $(this).ekkoLightbox();
	});
	</script>
	{% endaddtoblock %}

	{% addtoblock "js" %}
		<script type="text/javascript">
		$( document ).ready(function() {
			$('.pricingPopover').popover();	
		});
		</script>
	{% endaddtoblock %}
{% endblock %}

{% endif %}

{% endblock %}
