{% extends 'happenings/middle.html' %}
{% load staticfiles %}

{% block content %}
        <h1>{{ event.title }}</h1>
        <p>{{ event.description }}</p>

        {% if event.start_end_diff %}
            <b>This is a {{ event.start_end_diff|add:"1" }} day event.</b><br>
        {% endif %}

        {% if next_event %}
        <b>This event repeats {{ repeat | lower }}.</b>
            <p>
                Next event date: 
                    {{ next_event|date:"D F d, Y" }}
                    {{ event.start_date|date:"g:i a" }} -
                    {{ event.end_date|date:"g:i a e" }}{% if next_or_prev_cncl %} (CANCELLED){% endif %}
        {% elif last_event %}
            <b>This was an event that repeated {{ repeat | lower }}.</b>
            <p>The last event was on {{ last_event|date:"D F d, Y" }}{% if next_or_prev_cncl %} (CANCELLED){% endif %}
        {% else %}
            <p>When:
            {% if event_days %}
                <ul>
                {% for e in event_days %}
                    <li>
                        Day {{ forloop.counter }}: {{ e|date:"D F d, Y" }} - {{ event.end_date|date:"g:i a e" }}
                        {% for c in event.cancellations.all %}
                            {% if c.date == e.date %}
                                (CANCELLED)
                            {% endif %}
                    </li>
                    {% endfor %}
                {% endfor %}
                </ul>
            {% else %}
                    {{ event.start_date|date:"D F d, Y" }} - {{ event.end_date|date:"g:i a e" }}
                    {% if this_cncl %} (CANCELLED){% endif %}
            {% endif %}
        {% endif %}
        (today is: {% now "D M d, Y" %})</p>
        {% if cncl_days %}
            <p>This event has been cancelled on the following day(s):</p>
            <ul>
            {% for d, reason in cncl_days %}
                <li>{{ d|date:"D F d, Y" }} - Reason: {{ reason }}</li>
            {% endfor %}
            </ul>
        {% endif %}

        {% if event.location.all %}
        <p>Location{{ event.location.all|pluralize }}:<br>
        {% for l in event.location.all %}
            {{ l.name }}<br>
            {% if l.address_line_1 %}{{ l.address_line_1 }}<br>{% endif %}
            {% if l.address_line_2 %}{{ l.address_line_2 }}<br>{% endif %}
            {% if l.address_line_3 %}{{ l.address_line_3 }}<br>{% endif %}
            {% if l.city %}{{ l.city }},{% endif %} 
            {% if l.state %}{{ l.state }}{% endif %} 
            {% if l.zipcode %}{{ l.zipcode }}<br>{% endif %}
            {% if l.country %}{{ l.country }}<br>{% endif %}
        {% endfor %}
        </p>
        {% endif %}


        {% if event.categories.all %}
            Categor{{ event.categories.all|pluralize:"y,ies" }}:
            <ul>
                {% for category in event.categories.all %}
                <li>{{ category.title }}</li>
                {% endfor %}
            </ul>
        {% endif %}

        {% if event.tags.all %}
            Tag{{ event.tags.all|pluralize }}:
            <ul>
                {% for tag in event.tags.all %}
                <li>{{ tag.name }}</li>
                {% endfor %}
            </ul>
        {% endif %}

{% endblock content %}
