{% load i18n static cosinnus_tags thumbnail %}

{% if request.user.is_authenticated %}
    {% if societies or societies_invited %}
        <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                {% trans "Groups" %}
                <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu">
                {% for g in societies|slice:":30" %}
                    <li{% if g == appsmenu_society %} class="active"{% endif %}><a href="{% group_url 'cosinnus:group-dashboard' group=g %}">{{ g.name }}</a></li>
                {% endfor %}
                {% if societies|length > 30 %}
                	<li><a href="{% url 'cosinnus:group__group-list' %}...</a></li>
                {% endif %}
                {% if societies_invited %}
	                {% for g in societies_invited|slice:":30" %}
	                    <li class="inactive{% if g == appsmenu_society %} active{% endif %}"><a href="{% group_url 'cosinnus:group-dashboard' group=g %}">{{ g.name }} ({% trans "Invited to be a member" %})</a></li>
	                {% endfor %}
	                {% if societies_invited|length > 30 %}
	                	<li>...</li>
	                {% endif %}
                {% endif %}
                <li class="divider"></li>
                {% if societies_invited %}
                    <li><a href="{% url 'cosinnus:group__group-list-invited' %}">{% trans "Invited Groups" %}</a></li>
                {% endif %}
                {% if societies %}
                	<li><a href="{% url 'cosinnus:group__group-list-mine' %}">{% trans "My Groups" %}</a></li>
                {% endif %}
                <li><a href="{% url 'cosinnus:group__group-list' %}">{% trans "All Groups" %}</a></li>
            </ul>
        </li>
    {% else %}
        <li><a href="{% url 'cosinnus:group__group-list' %}">{% trans "Groups" %}</a></li>
    {% endif %}

    {% if groups or groups_invited %}
        <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                {% trans "Projects" %}
                <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu">
                {% for g in groups|slice:":30" %}
                    <li{% if g == appsmenu_group %} class="active"{% endif %}><a href="{% group_url 'cosinnus:group-dashboard' group=g %}">{{ g.name }}</a></li>
                {% endfor %}
                {% if groups|length > 30 %}
                	<li><a href="{% url 'cosinnus:group-list' %}">...</a></li>
                {% endif %}
                {% if groups_invited %}
	                {% for g in groups_invited|slice:":30" %}
	                    <li class="inactive{% if g == appsmenu_society %} active{% endif %}"><a href="{% group_url 'cosinnus:group-dashboard' group=g %}">{{ g.name }} ({% trans "Invited to be a member" %})</a></li>
	                {% endfor %}
	                {% if groups_invited|length > 30 %}
	                	<li>...</li>
	                {% endif %}
                {% endif %}
                <li class="divider"></li>
                {% if groups_invited %}
                    <li><a href="{% url 'cosinnus:group-list-invited' %}">{% trans "Invited Projects" %}</a></li>
                {% endif %}
                <li><a href="{% url 'cosinnus:group-list-mine' %}">{% trans "My Projects" %}</a></li>
                <li><a href="{% url 'cosinnus:group-list' %}">{% trans "All Projects" %}</a></li>
            </ul>
        </li>
    {% else %}
        <li><a href="{% url 'cosinnus:group-list' %}">{% trans "Projects" %}</a></li>
    {% endif %}
    
{% else %}
    <li><a href="{% url 'cosinnus:group__group-list' %}">{% trans "Groups" %}</a></li>
    <li><a href="{% url 'cosinnus:group-list' %}">{% trans "Projects" %}</a></li>
{% endif %}
