mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
88 lines
3.8 KiB
Django/Jinja
88 lines
3.8 KiB
Django/Jinja
{% extends "core/base.jinja" %}
|
|
{% from 'core/macros.jinja' import user_profile_link %}
|
|
|
|
{% block title %}
|
|
{% if object %}
|
|
{% trans %}Edit news{% endtrans %}
|
|
{% else %}
|
|
{% trans %}Create news{% endtrans %}
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if 'preview' in request.POST.keys() %}
|
|
<section class="news_event">
|
|
<h4>{{ form.instance.title }}</h4>
|
|
<p class="date">
|
|
<span>{{ form.instance.dates.first().start_date|localtime|date(DATETIME_FORMAT) }}
|
|
{{ form.instance.dates.first().start_date|localtime|time(DATETIME_FORMAT) }}</span> -
|
|
<span>{{ form.instance.dates.first().end_date|localtime|date(DATETIME_FORMAT) }}
|
|
{{ form.instance.dates.first().end_date|localtime|time(DATETIME_FORMAT) }}</span>
|
|
</p>
|
|
<p><a href="#">{{ form.instance.club or "Club" }}</a></p>
|
|
<div>{{ form.instance.summary|markdown }}</div>
|
|
<div>{{ form.instance.content|markdown }}</div>
|
|
<p>{% trans %}Author: {% endtrans %} {{ user_profile_link(form.instance.author) }}</p>
|
|
</section>
|
|
{% endif %}
|
|
{% if object %}
|
|
<h2>{% trans %}Edit news{% endtrans %}</h2>
|
|
{% else %}
|
|
<h2>{% trans %}Create news{% endtrans %}</h2>
|
|
{% endif %}
|
|
<form action="" method="post">
|
|
{% csrf_token %}
|
|
{{ form.non_field_errors() }}
|
|
{{ form.author }}
|
|
<p>{{ form.type.errors }}<label for="{{ form.type.name }}">{{ form.type.label }}</label>
|
|
<ul>
|
|
<li>{% trans %}Notice: Information, election result - no date{% endtrans %}</li>
|
|
<li>{% trans %}Event: punctual event, associated with one date{% endtrans %}</li>
|
|
<li>{% trans %}Weekly: recurrent event, associated with many dates (specify the first one, and a deadline){% endtrans %}</li>
|
|
<li>{% trans %}Call: long time event, associated with a long date (election appliance, ...){% endtrans %}</li>
|
|
</ul>
|
|
{{ form.type }}</p>
|
|
<p class="date">{{ form.start_date.errors }}<label for="{{ form.start_date.name }}">{{ form.start_date.label }}</label> {{ form.start_date }}</p>
|
|
<p class="date">{{ form.end_date.errors }}<label for="{{ form.end_date.name }}">{{ form.end_date.label }}</label> {{ form.end_date }}</p>
|
|
<p class="until">{{ form.until.errors }}<label for="{{ form.until.name }}">{{ form.until.label }}</label> {{ form.until }}</p>
|
|
<p>{{ form.title.errors }}<label for="{{ form.title.name }}">{{ form.title.label }}</label> {{ form.title }}</p>
|
|
<p>{{ form.club.errors }}<label for="{{ form.club.name }}">{{ form.club.label }}</label> {{ form.club }}</p>
|
|
<p>{{ form.summary.errors }}<label for="{{ form.summary.name }}">{{ form.summary.label }}</label> {{ form.summary }}</p>
|
|
<p>{{ form.content.errors }}<label for="{{ form.content.name }}">{{ form.content.label }}</label> {{ form.content }}</p>
|
|
{% if user.is_com_admin %}
|
|
<p>{{ form.automoderation.errors }}<label for="{{ form.automoderation.name }}">{{ form.automoderation.label }}</label>
|
|
{{ form.automoderation }}</p>
|
|
{% endif %}
|
|
<p><input type="submit" name="preview" value="{% trans %}Preview{% endtrans %}" /></p>
|
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
|
</form>
|
|
{% endblock %}
|
|
|
|
{% block script %}
|
|
{{ super() }}
|
|
<script>
|
|
$( function() {
|
|
var type = $('input[name=type]');
|
|
var dates = $('.date');
|
|
var until = $('.until');
|
|
function update_targets () {
|
|
type_checked = $('input[name=type]:checked');
|
|
if (type_checked.val() == "EVENT" || type_checked.val() == "CALL") {
|
|
dates.show();
|
|
until.hide();
|
|
} else if (type_checked.val() == "WEEKLY") {
|
|
dates.show();
|
|
until.show();
|
|
} else {
|
|
dates.hide();
|
|
until.hide();
|
|
}
|
|
}
|
|
update_targets();
|
|
type.change(update_targets);
|
|
} );
|
|
</script>
|
|
{% endblock %}
|
|
|
|
|