You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

190 lines
7.3 KiB

{% extends 'base.html' %}
{% load static %}
{# Displays article form #}
{% block scripts %}
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>
{# selects #}
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/>
<script src="{% static 'js/select/select2.js' %}"></script>
<script src="{% static 'custom_js/make_select.js' %}"></script>
{# ajax #}
<script src="{% static 'custom_js/file_post_ajax.js' %}"></script>
<script src="{% static 'custom_js/file_delete_ajax.js' %}"></script>
<script src="{% static 'custom_js/select_tag.js' %}"></script>
{% endblock %}
{% block body %}
{# Uses multilang.html template for translated fields #}
<form method="post" class="form-horizontal" name="form2" id="form2"> {% csrf_token %}
<fieldset>
<legend><i class="icon-edit"></i>{% if obj_id %} Изменить {% else %} Добавить {% endif %}статью</legend>
<div class="box span8">
<div class="box-header well">
<h2><i class="icon-pencil"></i> Основная информация</h2>
</div>
<div class="box-content">
{# Hidden inputs uses for comparing with TmpFile objects #}
{{ form.key }}
{# main_title #}
{% with field='main_title' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# theme #}
<div class="control-group {% if form.theme.errors %}error{% endif %}">
<label class="control-label"><b>{{ form.theme.label }}:</b></label>
<div class="controls">
{{ form.theme }}
<span class="help-inline">{{ form.theme.errors }}</span>
</div>
</div>
{# tag #}
<div class="control-group {% if form.tag.errors %}error{% endif %}">
<label class="control-label">{{ form.tag.label }}:</label>
<div class="controls">
{{ form.tag }}
<span class="help-inline">{{ form.tag.errors }}</span>
</div>
</div>
{# preview #}
{% with field='preview' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# author #}
<div class="control-group {% if form.author.errors %}error{% endif %}">
<label class="control-label">{{ form.author.label }}:</label>
<div class="controls">
{{ form.author }}
<span class="help-inline">{{ form.author.errors }}</span>
</div>
</div>
{# description #}
{% with field='description' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# keywords #}
{% with field='keywords' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# title #}
{% with field='title' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# descriptions #}
{% with field='descriptions' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
</div>
</div>
<div class="box span8" id="file">
<div class="box-header well">
<h2><i class="icon-pencil"></i> Файлы</h2>
</div>
<div class="box-content">
{# button that shows modal window with file form #}
<a href="#myModal" id="file_add" role="button" class="btn btn-info" data-toggle="modal">Добавить файл</a>
{# this div shows list of files and refreshes when new file added #}
<div id="file_list">
<table class="table table-hover">
<thead>
<tr>
<td>id</td>
<td>Файл</td>
<td>Имя</td>
<td>Назначение</td>
<td></td>
</tr>
</thead>
<tbody>
{% for file in files %}
<tr>
<td>{{ file.id }}</td>
<td><img src="{{ file.file_path.url }}"></td>
<td>{{ file.file_name }}</td>
<td>{{ file.purpose }}</td>
<td>
<button class="btn btn-danger delete_file" value="{{ file.id }}">
<i class="icon-trash icon-white"></i> Удалить
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="controls">
<input class="btn btn-large btn-primary" type="submit" value="Добавить">
<input class="btn btn-large" type="reset" value="Отмена">
</div>
</fieldset>
</form>
{# modal window #}
<div class="modal hide fade" id="myModal" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close">&times;</button>
<h3>Добавить файл</h3>
</div>
<div id="form_body">
<div class="modal-body">
<form method="post" class="form-horizontal" enctype="multipart/form-data" name="file_form" id="file_form" > {% csrf_token %}
{# hidden inputs uses for comparing with Article form key#}
{{ file_form.key }}
{{ file_form.model }}
<input type="hidden" id="obj_id" value="{{ obj_id }}">
{# file_path #}
<div class="control-group{% if file_form.file_path.errors %}error{% endif %}">
<label class="control-label"><b>{{ file_form.file_path.label }}:</b></label>
<div class="controls">{{ file_form.file_path }}
<span class="help-inline">{{ file_form.file_path.errors }}</span>
</div>
</div>
{# file purpose #}
<div class="control-group{% if file_form.purpose.errors %}error{% endif %}">
<label class="control-label"><b>{{ file_form.purpose.label }}:</b></label>
<div class="controls">{{ file_form.purpose }}
<span class="help-inline">{{ file_form.purpose.errors }}</span>
</div>
</div>
{# file_name #}
{% with field='file_name' form=file_form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# file_description #}
{% with field='description' form=file_form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
</div>
<div class="modal-footer">
<div class="controls">
<input class="btn btn-primary" type="submit" value="Добавить">
<input type="reset" class="btn" value="Отменить" data-dismiss="modal">
</form>
</div>
</div>
</div>
</div>
{% endblock %}