{% extends "cranefly/usercp/layout.html" %}
{% import "_forms.html" as form_theme with context %}
{% import "cranefly/macros.html" as macros with context %}

{% block title %}{{ macros.page_title(title=_('Change your Username')) }}{% endblock %}

{% block action %}
<div class="form-container">

  <div class="form-header">
    <h1>{% trans %}Change your Username{% endtrans %}</h1>
  </div>

  {% if message %}
  <div class="messages-list">
    {{ macros.draw_message(message) }}
  </div>
  {% endif %}

  <form action="{% url 'usercp_username' %}" method="post">
    <div class="form-fields">
      {% if changes_left == 0 %}
      {% do form.fields['username']['attrs'].update({'disabled': 'disabled'}) %}
      {% endif %}
      {{ form_theme.form_widget(form, width=9) }}
    </div>
    <div class="form-actions">
      <button name="save" type="submit" class="btn btn-primary"{% if changes_left == 0 %} disabled="disabled"{% endif %}>{% trans %}Change Name{% endtrans %}</button>
      <span class="form-actions-protip">{% if changes_left > 0 -%}
      {% trans changes=changes_left -%}
      You can change your username one more time.
      {%- pluralize -%}
      You can change your username {{ changes }} more times.
      {%- endtrans %}
      {%- elif acl.usercp.changes_expire() -%}
      {% trans next_change=next_change|reldate|low %}You will be able to change your username on {{ next_change }}{% endtrans %}
      {%- else -%}
      {% trans %}You have exceeded the maximum number of name changes.{% endtrans %}
      {%- endif %}
      </span>
    </div>
  </form>
</div>
{% endblock %}