{% load i18n %}

<div class="approval-widget">
    {% if can_edit %}
        <a href="{% url 'publisher:publisher_course_runs_edit' pk=object.id %}" class="btn btn-neutral btn-courserun-edit">
            {% trans "EDIT" %}
        </a>
        <div class="clearfix"></div>
    {% endif %}
    {% for role_widget in  role_widgets %}
        <div class="role-widget">
            <span class="role-heading">
                <strong>{{ role_widget.heading }}</strong>
            </span>
            <div class="role-assignment-container">
                <div id="userRoleContainer-{{ role_widget.user_course_role.role }}">
                    <span id="userFullName-{{ role_widget.user_course_role.role }}" class="field-readonly user-full-name">
                        {{ role_widget.user_course_role.user.full_name }}
                    </span>
                    <a class="change-role-assignment" data-role="{{ role_widget.user_course_role.role }}" href="#">
                        {% trans "change owner" %}
                    </a>
                </div>
                <div class="change-role-container" id="changeRoleContainer-{{ role_widget.user_course_role.role }}">
                    <select class="select-users-by-role" id="selectUsers-{{ role_widget.user_course_role.role }}">
                        {% for user in user_list %}
                            <option {% if role_widget.user_course_role.user == user%}selected="selected"{% endif %} value="{{ user.id }}">
                                {{ user.full_name }}
                            </option>
                        {% endfor %}
                    </select>
                    <input type="hidden" id="roleName" value="{{ role_widget.user_course_role.role }}">
                    <button type="button" class="btn-neutral btn-change-assignment" data-role="{{ role_widget.user_course_role.role }}" data-api-endpoint="{% url 'publisher:api:course_role_assignments' role_widget.user_course_role.id %}">
                        {% trans "CHANGE" %}
                    </button>
                </div>
            </div>
        </div>
        <hr>
    {% endfor %}

    <div class="actions">
        <form action="{% url 'publisher:publisher_change_state' pk=object.id %}" method="post"> {% csrf_token %}
            <button type="submit" value="{{ object.change_state_button.value }}" class="btn-brand btn-small btn-states" name="state">{{ object.change_state_button.text }}</button>
        </form>
    </div>

    <div class="comment-container">
        {% include 'comments/comments_list.html' %}
        {% include 'comments/add_auth_comments.html' %}
    </div>
</div>
