{% extends "cfp/event/base.html" %}
{% load bootstrap4 %}
{% load compress %}
{% load html_signal %}
{% load i18n %}
{% load static %}

{% block title %}{% translate "Your Profile" %} :: {% endblock %}

{% block content %}
    {% if profile_form.biography %}
        <script src="{% static "vendored/marked.min.js" %}" defer></script> {# do not compress #}
        <script src="{% static "common/js/markdown.js" %}" defer></script>
    {% endif %}

    {% html_signal "pretalx.cfp.signals.html_above_profile_page" sender=request.event request=request %}

    <h2>{% translate "Your Profile" %}</h2>
    <p>
        {% translate "This data will be displayed publicly if your proposal is accepted. It is also visible to reviewers." %}
    </p>
    <form method="post" enctype="multipart/form-data" class="speaker-profile-form">
        {% csrf_token %}
        {% bootstrap_form_errors profile_form %}
        {% if request.event.settings.cfp_request_avatar %}
            {% include "common/avatar.html" with user=request.user form=profile_form %}
        {% endif %}
        {% bootstrap_field profile_form.name layout='event' %}
        {% if profile_form.biography %}{% bootstrap_field profile_form.biography layout='event' %}{% endif %}
        {% if profile_form.availabilities %}
            {% compress js %}
                <script defer src="{% static "vendored/moment-with-locales.js" %}"></script>
                <script defer src="{% static "vendored/moment-timezone-with-data-2012-2022.js" %}"></script>
            {% endcompress %}
            {% include "common/availabilities.html" %}
            {% bootstrap_field profile_form.availabilities layout='event' %}
        {% endif %}
        <div class="row">
            <div class="col-md-4 ml-auto">
                <button type="submit" class="btn btn-block btn-success btn-lg" name="form" value="profile">
                    {% translate "Save" %}
                </button>
            </div>
        </div>
    </form>

    {% if questions_exist %}
        <h2>{% translate "We have some questions" %}</h2>
        <form method="post" enctype="multipart/form-data">
            {% csrf_token %}
            {% bootstrap_form questions_form layout='event' %}
            <div class="row">
                <div class="col-md-4 ml-auto">
                    <button type="submit" class="btn btn-block btn-success btn-lg" name="form" value="questions">
                        {% translate "Save" %}
                    </button>
                </div>
            </div>
        </form>
    {% endif %}

    <h2>{% translate "Your Account" %}</h2>
    <p>
        {% translate "You can change your log in data here." %}
    </p>
    <form method="post" class="form password-input-form">
        {% csrf_token %}
        {{ login_form.media }}
        {% bootstrap_field login_form.old_password layout='event' %}
        {% bootstrap_field login_form.email layout='event' %}
        {% bootstrap_field login_form.password layout='event' %}
        {% bootstrap_field login_form.password_repeat layout='event' %}
        <div class="row">
            <div class="col-md-4 ml-auto">
                <button type="submit" class="btn btn-block btn-success btn-lg" name="form" value="login">
                    {% translate "Save" %}
                </button>
            </div>
        </div>
    </form>
    {% include "common/user_api_token.html" %}
    <div>&nbsp;</div>
    <h3>{% translate "Account deletion" %}</h3>
    <form action="{{ request.event.urls.user_delete }}" method="post" class="form">
        {% csrf_token %}
        <div class="alert alert-danger">
            {% translate "You can delete your account here – all names, emails, and other personal information will be overwritten. <strong>This action is irreversible.</strong>" %}
        </div>
        <div class="form-group"{% if not "really" in request.GET %} style="visibility:hidden;"{% endif %}>
            <input type="checkbox" name="really" id="really">
            <label class="form-control-label" for="really">{% translate "I really do want to delete my account, losing access to my proposals and sessions, and overriding my public and private data." %}</label>
        </div>
        <div class="col-md-4 ml-auto">
            <button type="submit" class="btn btn-block btn-danger btn-lg" name="form" value="">
                {% translate "Delete my account" %}
            </button>
        </div>
    </form>
    {% compress js %}
        <script defer src="{% static "cfp/js/profile.js" %}"></script>
    {% endcompress %}
{% endblock %}
