{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "upload/attachments.html" import attachments_form %}
{% from "includes/common_macros.html" import content_editor %}
{# L10n: {t} is the title of the question. #}
{% set title = _('Editing an answer | {t} | Firefox Support Forum')|f(t=answer.question.title) %}
{% set classes = 'answers' %}

{% block content %}
  <article class="main">
    <div class="edit-answer">
      <h2>{{ _('Edit an answer') }}</h2>
      <ul class="info">
        <li>
          <label>{{ _('Created by:') }}</label>
          {{ answer.creator }}
        </li>
        <li>
          <label>{{ _('Created:') }}</label>
          {{ datetimeformat(answer.created, format='longdatetime') }}
        </li>
        {% if answer.updated_by %}
          <li>
            <label>{{ _('Last updated by:') }}</label>
            {{ answer.updated_by }}
          </li>
          <li>
            <label>{{ _('Last updated:') }}</label>
            {{ datetimeformat(answer.updated, format='longdatetime') }}
          </li>
        {% endif %}
        <li>
          <label>{{ _('Question:') }}</label>
          {{ answer.question.title }}
        </li>
      </ul>
      <form action="{{ url('questions.edit_answer', answer.question.id, answer.id) }}" method="post">
        {{ csrf() }}
        {{ errorlist(form) }}

        <div class="form-widget{% if form.content.errors %} invalid{% endif %}">
          {{ content_editor(form.content) }}
        </div>

        {{ attachments_form('questions.Answer', answer.pk, answer.images.all(), settings, request.user) }}

        <div class="form-widget submit">
          <input type="submit" class="btn" value="{{ _('Update answer') }}" />
          <input type="submit" class="preview link-btn" name="preview" value="{{ _('Preview Reply') }}" />
          <a href="{{ url('questions.answers', answer.question.id) }}">{{ _('Cancel') }}</a>
        </div>
      </form>

      {% if answer_preview %}
        <section id="answer-preview">
          <header>
            <h1>{{ _('Answer Preview:') }}</h1>
          </header>
          <ol class="answers">
            <li class="answer">
              {% set answer = answer_preview %}
              {% set question = answer.question %}
              {% include "questions/includes/answer.html" %}
            </li>
          </ol>
        </section>
      {% endif %}
    </div>
  </article>
{% endblock %}

{% block side %}
{% endblock %}
