{% extends 'base.html' %}
{% load static %}
{% load placeholder_filters %}

{% block bodydata %}
    data-project-id="{{ project.id }}"
    data-project-locked="{{ project.islocked }}"
{% endblock %}

{% block title %} | Project: {{ project.name }} - Social interactions{% endblock %}

{% block main %}
    <div class="page-header" xmlns="http://www.w3.org/1999/html">
        <div class="container">
            <h1 class="smaller">
                {% if project.islocked %}<span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}
                <a href="{% url 'admin:project_overview' project.id %}">{{ project.name }}</a>
            </h1>
            {% include 'projects/navigation.html' %}
        </div>
    </div>

    <div class="container">
        {% include 'snippets/messages.html' %}
        <!-- social pull list -->
        <div class="row">
{#            <div class="col-md-6 col-md-push-6">#}
{#                <h3 class="header">#}
{#                    {% if project.islocked %}#}
{#                        <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}#}
{#                    <span>Pull from social media</span>#}
{#                    {% if not project.islocked %}#}
{#                        <a href="{% url 'admin:socialinteraction_pull_create' project.id %}"#}
{#                           class="btn btn-success btn-sm pull-right">#}
{#                            <span class="glyphicon glyphicon-plus"></span>#}
{#                            Create new pull task#}
{#                        </a>#}
{#                    {% endif %}#}
{#                </h3>#}
{##}
{#                {% for si_pull in project.socialinteractions_pull.all %}#}
{#                    {% if forloop.first %}#}
{#                        <ul class="list-unstyled overview-list">#}
{#                    {% endif %}#}
{##}
{#                <li>#}
{#                    <h5>#}
{#                        {% if si_pull.islocked %}#}
{#                            <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}#}
{#                        <p>{% if si_pull.socialaccount %}#}
{#                            <img class="socialaccount_provider" src="#}
{#                                    {% static 'img/providers/' %}{{ si_pull.socialaccount.provider }}.svg"#}
{#                                 alt="{{ si_pull.socialaccount.get_provider.name }} social provider"/>#}
{#                            {{ si_pull.socialaccount.provider|capfirst }} account:#}
{#                            {% if si_pull.socialaccount.provider == 'twitter' %}@{% endif %}{{ si_pull.socialaccount.get_provider_account }}{% endif %}#}
{#                    </h5>#}
{#                    <p>{% if si_pull.status == 'inactive' %}#}
{#                        <span class="glyphicon glyphicon-pause"></span>{% else %}#}
{#                        <span class="glyphicon glyphicon-play">  </span>{% endif %} <a#}
{#                            href="{% url 'admin:socialinteraction_pull_settings' project.id si_pull.id %}">Text to#}
{#                        pull ({{ si_pull.frequency }}): </a></br>#}
{#                        {% autoescape off %}#}
{#                            {{ si_pull.text_to_pull }}{% endautoescape %}#}
{#                    </p>#}
{#                </li>#}
{##}
{#                {% if forloop.last %}#}
{#                    </ul>#}
{#                {% endif %}#}
{#                {% empty %}#}
{#                    <div class="well empty-list">#}
{#                        <p class="lead">We couldn't find any social interactions for this project.</p>#}
{##}
{#                        {% if project.islocked %}#}
{#                            <p>Unfortunately, you cannot create new social interactions when the project is locked.</p>#}
{#                        {% else %}#}
{#                            <a href="{% url 'admin:socialinteraction_pull_create' project.id %}"#}
{#                               class="btn btn-success btn-lg">Create new pull task</a>#}
{#                        {% endif %}#}
{#                    </div>#}
{#                {% endfor %}#}
{#            </div>#}
            <!-- social post list -->
{#            <div class="col-md-6 col-md-push-6">#}
            <div class="col-md-12">
                <h3 class="header">
                    {% if project.islocked %}
                        <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}
{#                    <span>Post to social media</span>#}
                    <span>Post to Twitter</span>
                    {% if not project.islocked %}
                        <a href="{% url 'admin:socialinteraction_post_create' project.id %}"
                           class="btn btn-success btn-sm pull-right">
                            <span class="glyphicon glyphicon-plus"></span>
                            Create new post task
                        </a>
                    {% endif %}
                </h3>

                {% for socialinteraction in project.socialinteractions_post.all %}
                    {% if forloop.first %}
                        <ul class="list-unstyled overview-list">
                    {% endif %}

                <li>
                    <h5>
                        {% if socialinteraction.islocked %}
                            <span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}
                        <p>{% if socialinteraction.socialaccount %}
                            <img class="socialaccount_provider" src="
                                    {% static 'img/providers/' %}{{ socialinteraction.socialaccount.provider }}.svg"
                                 alt="{{ socialinteraction.socialaccount.get_provider.name }} social provider"/>
                            {{ socialinteraction.socialaccount.provider|capfirst }} account:
                            {% if socialinteraction.socialaccount.provider == 'twitter' %}@{% endif %}{{ socialinteraction.socialaccount.get_provider_account }}{% endif %}
                    </h5>
                    <p>{% if socialinteraction.status == 'inactive' %}
                        <span class="glyphicon glyphicon-pause"></span>{% else %}
                        <span class="glyphicon glyphicon-play">  </span>{% endif %} <a
                            href="{% url 'admin:socialinteraction_post_settings' project.id socialinteraction.id %}">Text to
                        post:</a></br>
                        {% autoescape off %}
                            {{ socialinteraction.text_to_post|add_link:socialinteraction.link }}{% endautoescape %}
                    </p>
                </li>

                {% if forloop.last %}
                    </ul>
                {% endif %}
                {% empty %}
                    <div class="well empty-list">
                        <p class="lead">We couldn't find any social interactions for this project.</p>

                        {% if project.islocked %}
                            <p>Unfortunately, you cannot create new social interactions when the project is locked.</p>
                        {% else %}
                            <a href="{% url 'admin:socialinteraction_post_create' project.id %}"
                               class="btn btn-success btn-lg">Create new post task</a>
                        {% endif %}
                    </div>
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}


{% block libraries %}
    <script src="/static/js/admin.ui.forms.validate.js"></script>
    <style>
        #breakable {
            word-break: break-all;
            color: #9d9d9d;
        }

    </style>
{% endblock %}
