{% extends 'publisher/base.html' %}
{% load i18n %}
{% load static %}

{% block title %}
    {% trans "Edit Course Run" %}
{% endblock title %}

{% block page_content %}
<div>
<h1 class="hd-1 emphasized">
    {% trans "Edit Course Run" %}
</h1>

<div class="alert-messages">
{% if messages %}
    {% for message in messages %}
    <div class="alert alert-{{ message.tags }}" role="alert" aria-labelledby="alert-title-{{ message.tags }}" tabindex="-1">
        <div><p class="alert-copy">{{ message }}</p></div>
    </div>
    {% endfor %}
{% endif %}
<p>
    {% blocktrans with span_start='<span class="required">' span_end='</span>' trimmed %}
        {{ span_start }}* All required fields must be complete before this course run can be sent for review.{{ span_end }}
    {% endblocktrans %}
</p>
<p>
    {% blocktrans with strong_start='<strong>' strong_end='</strong>' trimmed %}
        {{ strong_start }}Note:{{  strong_end }} If you edit course information after edX marketing has reviewed the course, you have to send the course to edX marketing for review again.
    {% endblocktrans %}
</p>
<form class="form" method="post" action="" enctype="multipart/form-data">
{% csrf_token %}
<div class="layout-full layout">
    <div class="course-form">
        <div class="course-information">
            <fieldset class="form-group grid-container grid-manual">
                <div class="field-title">{% trans "COURSE START DATE" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        <ul>
                            <li>
                                {% trans "Note that times use UTC." %}
                            </li>
                            <li>
                                {% trans "Start on a Tuesday, Wednesday, or Thursday." %}
                            </li>
                            <li>
                                {% trans "Avoid major U.S. holidays." %}
                            </li>
                            <li>
                                {% trans "Specify a month, day, and year. If you are unsure of the exact date, specify a day that is close to the estimated start date. For example, if your course will start near the end of March, specify March 31." %}
                            </li>
                        </ul>
                    </div>
                    <div class="col col-6">
                        <label class="field-label ">{{ run_form.start.label_tag }}  <span class="required">*</span></label>
                        {{ run_form.start }}
                        {% if run_form.start.errors %}
                            <div class="field-message-content">
                            {{ run_form.start.errors|escape }}
                            </div>
                        {% endif %}
                    </div>
                </div>

                <div class="field-title">{% trans "COURSE END DATE" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "Note that times use UTC. Specify a month, day, and year. If you are unsure of the exact date, specify a day that is close to the estimated end date. For example, if your course will end near the end of March, specify March 31." %}
                    </div>
                    <div class="col col-6">
                        <label class="field-label ">{{ run_form.end.label_tag }}  <span class="required">*</span></label>
                        {{ run_form.end }}
                    </div>
                </div>

                <div class="field-title">{% trans "COURSE PACING" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        <p>{% trans "Instructor-paced courses include individual assignments that have specific due dates before the course end date." %} </p>
                        <p>{% trans "Self-paced courses do not have individual assignments that have specific due dates before the course end date. All assignments are due on the course end date." %}</p>
                    </div>
                    <div class="col col-6">
                        <label class="field-label">{{ run_form.pacing_type.label_tag }}  <span class="required">*</span></label>
                        <div class="checkbox-inline">{{ run_form.pacing_type }}</div>
                    </div>
                </div>

                <div class="field-title">{% trans "STUDIO URL" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        <p>{% trans "The Studio URL for this course run. The edX PC creates this URL." %}</p>
                    </div>
                    <div class="col col-6">
                        <label class="field-label ">{{ run_form.lms_course_id.label_tag }}  <span class="required">*</span></label>
                        {{ run_form.lms_course_id }}

                        {% if not is_project_coordinator %}
                            <div class="studio-url">
                                <span class="studio-url-heading">{% trans "STUDIO URL" %} - </span>
                                {% if course_run.studio_url %}
                                    <a class="studio-link" href="{{ course_run.studio_url }}" target="_blank">{{ course_run.lms_course_id }}</a>
                                {% else %}
                                    {% trans "Not yet created" %}
                                {% endif %}
                            </div>
                        {% endif %}
                    </div>
                </div>
            </fieldset>
        </div>
        <div id="about-page" class="course-information {% if publisher_hide_features_for_pilot %}hidden{% endif %}">
            <fieldset class="form-group grid-container grid-manual">
                <div class="field-title">{% trans "PROGRAM ASSOCIATION" %} <span class="optional float-right">Optional</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "If this course is part of a program, select the program type, and then enter the name of the program." %}
                    </div>
                    <div class="col col-6">
                        <div class="row">
                            <div class="col col-5">
                                <label class="field-label ">{{ run_form.is_micromasters.label_tag }}</label>
                                {{ run_form.is_micromasters}}
                            </div>
                            <div class="col col-7 {% if run_form.micromasters_name %} hidden {% endif %}" id="micromasters_name_group">
                                <label class="field-label ">{{ run_form.micromasters_name.label_tag }}</label>
                                {{ run_form.micromasters_name }}
                            </div>
                            {% if run_form.micromasters_name.errors %}
                            <div class="field-message-error">
                                <span>
                            {{ run_form.micromasters_name.errors|escape }}
                                </span>
                            </div>
                            {% endif %}
                        </div>
                        <div class="row">
                            <div class="col col-5">
                                <label class="field-label ">{{ run_form.is_professional_certificate.label_tag }}</label>
                                {{ run_form.is_professional_certificate}}
                            </div>
                            <div class="col col-7 {% if run_form.professional_certificate_name %} hidden {% endif %}" id="professional_certificate_group">
                                <label class="field-label ">{{ run_form.professional_certificate_name.label_tag }}</label>
                                {{ run_form.professional_certificate_name }}
                            </div>
                            {% if run_form.professional_certificate_name.errors %}
                            <div class="field-message-error">
                                <span>
                            {{ run_form.professional_certificate_name.errors|escape }}
                                </span>
                            </div>
                            {% endif %}
                        </div>
                        <div class="row">
                            <div class="col col-5">
                                <label class="field-label ">{{ run_form.is_xseries.label_tag }}</label>
                                {{ run_form.is_xseries}}
                            </div>
                            <div class="col col-7 {% if run_form.xseries_name %} hidden {% endif %}" id="xseries_name_group">
                                <label class="field-label ">{{ run_form.xseries_name.label_tag }}</label>
                                {{ run_form.xseries_name}}
                            </div>
                            {% if run_form.xseries_name.errors %}
                            <div class="field-messag-error">
                                <span class="field-message-content">
                                    {{ run_form.xseries_name.errors|escape }}
                                </span>
                            </div>
                            {% endif %}
                        </div>
                    </div>
                </div>

                <div class="field-title">{% trans "CERTIFICATE TYPE AND PRICE" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "If the course offers a verified or professional education certificate, select the certificate type and enter the price for the certificate." %}
                    </div>
                    <div class="col col-6">
                        <div class="row">
                            <div class="col col-6">
                                <label class="field-label ">{{ seat_form.type.label_tag }}
                                </label> {{ seat_form.type }}
                            </div>
                            <div id="SeatPriceBlock" class="col col-6 {% if seat_form.type.value == 'audit' or not seat_form.price.value %}hidden{% endif %}">
                                <label class="field-label ">{{ seat_form.price.label_tag }}</label>
                                {{ seat_form.price }}
                                <div class="{% if seat_form.type.value != 'credit' or not seat_form.credit_price.value %}hidden{% endif %}" id="creditPrice">
                                    <label class="field-label">{{ seat_form.credit_price.label }}</label>
                                    {{ seat_form.credit_price }}
                                </div>
                            </div>
                        </div>
                        {% if seat_form.price.errors %}
                            <div class="field-message has-error">
                                <span class="field-message-content">
                                    {{ seat_form.price.errors|escape }}
                                </span>
                            </div>
                        {% endif %}
                    </div>
                </div>

                <div class="field-title">{% trans "COURSE STAFF" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "The primary instructor or instructors for the course." %}
                    </div>
                    <div class="col col-6 instructor-select">
                        <label class="field-label ">{{ run_form.staff.label_tag }} <span class="required">*</span></label>
                        {{ run_form.staff }}
                        <div class="selected-instructor">
                          {% if publisher_add_instructor_feature %}
                            <button type="button" id="add-new-instructor">{% trans "Add New" %}<br>{% trans "Instructor" %}</button>
                          {% endif %}
                        </div>
                    </div>
                </div>

                <div class="field-title">{% trans "ESTIMATED EFFORT" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6">
                        {% trans "The number of hours per week the learner should expect to spend on the course. This may be a range." %}
                    </div>
                    <div class="col col-6">
                        <div class="row">
                            <div class="col col-6">
                                <label class="field-label ">{% trans "Min Effort" %}</label>
                                {{ run_form.min_effort }}
                                {% if run_form.min_effort.errors %}
                                    {{ run_form.min_effort.errors|escape }}
                                {% endif %}
                            </div>
                            <div class="col col-6">
                                <label class="field-label ">{% trans "Max Effort" %}</label>
                                {{ run_form.max_effort }}
                            </div>
                        </div>
                    </div>
                </div>

                <div class="field-title">{% trans "LANGUAGE(S)" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "The languages available for videos, video transcripts, and other course content." %}
                    </div>
                    <div class="col col-6">
                        <label class="field-label ">{{ run_form.language.label_tag }} <span class="required">*</span></label>
                        {{ run_form.language}}

                        <label class="field-label ">{{ run_form.transcript_languages.label_tag }} <span class="required">*</span></label>
                        {{ run_form.transcript_languages}}

                        <label class="field-label margin-top20">{{ run_form.video_language.label_tag }} <span class="required">*</span></label>
                        {{ run_form.video_language}}
                    </div>
                </div>

                <div class="field-title">{% trans "LENGTH" %} <span class="required float-right">* Required for review</span></div>
                <div class="row">
                    <div class="col col-6 help-text">
                        {% trans "The length of the course, in weeks, rounded to the nearest whole number." %}
                    </div>
                    <div class="col col-6">
                        <label class="field-label ">{{ run_form.length.label_tag }}</label>
                        {{ run_form.length}}
                    </div>
                </div>

            </fieldset>
        </div>
    </div>
</div>

<div class="course-form">
    <div class="course-information action-buttons">
        <a href="{% url 'publisher:publisher_course_run_detail' course_run.id %}">{% trans "Cancel" %}</a>
        <button class="btn-brand btn-base btn-save" type="submit">
            {% trans "Update Course Run" %}
        </button>
    </div>
</div>

</form>
</div>
</div>
{% if publisher_add_instructor_feature %}
    {% include "publisher/_add_instructor_popup.html" %}
{% endif %}
{% endblock %}

{% block extra_js %}
     <script src="{% static 'js/publisher/course-tabs.js' %}"></script>
     <script src="{% static 'js/publisher/organizations.js' %}"></script>
     <script src="{% static 'js/publisher/instructors.js' %}"></script>
     <script src="{% static 'js/publisher/seat-type-change.js' %}"></script>
     <script src="{% static 'js/publisher/image-validation.js' %}"></script>
     <script src="{% static 'js/publisher/program-types.js' %}"></script>
     <script src="{% static 'js/publisher/modal-screen.js' %}"></script>
{% endblock %}

{% block js_without_compress %}
    {{ run_form.media }}
{% endblock %}
