{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "questions/includes/question_editing_frame.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% set title = _('Ask a Question') %}

{% block headline %}{{ _('Ask a New Question') }}{% endblock %}

{# TODO: make these macros: register_form, login_form #}
{% block articles_and_search_results %}
  <h2>{{ _('Before you continue, we ask you to create a support account so we can contact you.') }}</h2>
  <p>{{ _('A support account lets us alert you when people respond to your question.') }}</p>
  <div id="register_form">
    <h2>{{ _('Create an account') }}</h2>
    {{ errorlist(register_form) }}
    <form method="post" action="">
      {{ csrf() }}
      <ul>
        {% for field in register_form %}
          <li>{{ field|label_with_help }} {{ field|safe }}</li>
        {% endfor %}
      </ul>
      <div class="submit">
        <input type="hidden" value="register" name="type" />
        <input type="submit" class="btn" value="{{ _('Register') }}" />
      </div>
    </form>
  </div>

  <div id="login_form">
    <h2>{{ _('I already have an account') }}</h2>
    {{ errorlist(login_form) }}
    <form method="post" action="">
      {{ csrf() }}
      <input type="hidden" name="next" value="{{ next_url }}" />
      <ul>
        <li>
          <label for="id_username">{{ _('Username:') }}</label>
          <input id="id_username" type="text" name="username" autofocus />
        </li>
        <li>
          <label for="id_password">{{ _('Password:') }}</label>
          {{ login_form.password|safe }}
        </li>
      </ul>
      <div class="submit">
        <input type="hidden" value="login" name="type" />
        <input type="submit" class="btn" value="{{ _('Log in') }}" data-progress="{{ _('Logging in...') }}" data-done="{{ _('Logged in!') }}" data-reset="{{ _('Log in') }}" />
      </div>
    </form>
    <a id="reset_password" target="_blank" href="{{ url('users.pw_reset') }}">{{ _("I forgot my password.") }}</a>
  </div>
{% endblock %}

{% block submit_button_value %}{{ _('Post Question') }}{% endblock %}
