{% extends "cfp/event/base.html" %}
{% load i18n %}
{% load bootstrap4 %}
{% load staticfiles %}
{% block title %}{% trans "Your Profile" %} :: {{ request.event }}{% endblock %}
{% block content %}
    <h2>{% trans "Your Profile" %}</h2>
    <p>
        {% trans "This data will be displayed next to your talk slots in the schedule." %}
    </p>
    <form action="" method="post" enctype="multipart/form-data" class="speaker-profile-form">
        {% csrf_token %}
        <div class="avatar-form">
            <div class="col-md-3 control-label">
            <img
              class="avatar"
              data-gravatar="{{ request.user.gravatar_parameter }}"
              data-avatar="{% if request.user.avatar %}{{ request.user.avatar.url }}{% endif %}"
              {% if request.user.get_gravatar %}
              src="https://www.gravatar.com/avatar/{{ request.user.gravatar_parameter }}"
              {% elif request.user.avatar and request.user.avatar != 'False' %}
              src="{{ request.user.avatar.url }}"
              {% endif %}
            />
            </div>
            <div class="avatar-form-fields">
                {% bootstrap_field profile_form.get_gravatar %}
                <div class="user-avatar-display">
                    {% bootstrap_field profile_form.avatar layout='inline' %}
                </div>
            </div>
        </div>
        {% bootstrap_field profile_form.name layout='event' %}
        {% bootstrap_field profile_form.biography layout='event' %}
        {% bootstrap_field profile_form.availabilities layout='event' %}
        <div class="row">
            <div class="col-md-3 ml-auto">
                <button type="submit" class="btn btn-block btn-success btn-lg" name="form" value="profile">
                    {% trans "Save" %}
                </button>
            </div>
        </div>
    </form>

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

    <h2>{% trans "Your Account" %}</h2>
    <p>
        {% trans "You can change your log in data here." %}
    </p>
    <form action="" 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-3 ml-auto">
                <button type="submit" class="btn btn-block btn-success btn-lg" name="form" value="login">
                    {% trans "Save" %}
                </button>
            </div>
        </div>
    </form>
    <div>&nbsp;</div>
    <h3>{% trans "Account deletion" %}</h3>
    <form action="{{ request.event.urls.user_delete }}" method="post" class="form">
        {% csrf_token %}
        <div class="alert alert-danger">
            {% trans "You can delete your account here – all names, emails etc 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">{% trans "I really do want to delete my account, losing access to my submissions and talks, and overriding my public and private data." %}</label>
            </div>
            <div class="col-md-3 ml-auto">
                <button type="submit" class="btn btn-block btn-danger btn-lg" name="form" value="">
                    {% trans "Delete my account" %}
                </button>
            </div>
    </form>
    <script type="text/javascript" src="{% static "cfp/js/profile.js" %}"></script>
{% endblock %}
