{% extends "revuo/base.html" %}

{% block title %}
{% endblock %}

{% block page_body %}

    <div class="container">
        {% if user.is_authenticated and not item.authorized %}
            <div class="warning-panel base-panel">
                <div class="alert alert-warning">
                    <h1>Pending Authorization</h1>
                </div>
            </div>
        {% endif %}

        {% block item_body %}
        {% endblock %}

        {% if user.is_authenticated and user.author.editor and not item.authorized %}
            <div class="actions-panel base-panel">
                <p>
                <button type='button' class="btn btn-primary" name='authorize' onclick="auth_item()">Authorize</button>
                <button type='button' class="btn btn-warning" name='delete' onclick="del_item()">Delete</button>
                </p>
            </div>
        {% endif %}
    </div>


{% endblock %}

{% block scripts %}
<script>
    function auth_item(){
        result = $.get("/restricted/publisher{{ item.get_url }}",
            function(data) {
                document.location.reload();
            }, 
            "json")
    }
    function del_item(){
        result = $.get("/restricted/trasher{{ item.get_url }}",
            function(data) {
                window.location.replace('/');
            },
            "json")
    }
</script>
{% endblock %}
