{% extends 'base.html' %}

{% load i18n %}

{% block content %}

{% block extra_js %}
    {{ form.media.js }}
{% endblock %}

<div class="container">

	<div class="mainbox col-md-8 col-md-offset-2 col-sm-6 col-sm-offset-3">
		{% for message in messages %}
			{% if message.tags != "error" %}
				<div class="alert alert-success" role="alert">
					<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
					{{ message }}
				</div>
			{% else %}
				<div class="alert alert-danger" role="alert">
					<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
					{{ message }}
				</div>
			{% endif %}
		{% endfor %}
		<div class="panel panel-default" >
            <div class="panel-heading">
                <div class="panel-title text-center">{% trans "Edit topic" %}</div>
            </div>

            <div class="panel-body">
            	<form class="form-horizontal" action="{{request.get_full_path}}" method="POST" enctype="multipart/form-data">{% csrf_token%}
            		{% for field in form %}
			   			{% if field.name == "title" %}
			   				<label>{% trans "Title" %}</label>
			              	{{ field }}
			              	{% if form.title.errors %}
			              		<div style="color: red">{{ form.title.errors }}</div>
			              	{% else %}
			              		<br>
			              	{% endif %}
			            {% endif %}
			            {% if field.name == "description" %}
			            	<label>{% trans "Description" %}</label>
			              	{{ field }}
			              	{% if form.description.errors %}
			              		<div style="color: red">{{ form.description.errors|safe }}</div>
			              	{% else %}
			              		<br>
			              	{% endif %}
			            {% endif %}
			          	{% if field.name == "attachment" %}
			            	<label>{% trans "Attachment" %}</label>
			              	{{ field }}
			              	{% if form.attachment.errors %}
			              		<div style="color: red">{{ form.attachment.errors }}</div>
			              	{% else %}
			              		<br>
			              	{% endif %}
			            {% endif %}
			        {% endfor %}
			        <button type="submit" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-floppy-disk"></i> {% trans "Save" %}</button>
				</form>
            </div>
        </div>
	</div>

</div>


{% endblock %}