Commit be44a3ab authored by Skia's avatar Skia

Add preview button to news

parent 1dc1a0a4
Pipeline #610 passed with stage
in 2 minutes and 34 seconds
......@@ -9,8 +9,6 @@
{% block content %}
<p><a href="{{ url('com:news_list') }}">{% trans %}Back to news{% endtrans %}</a></p>
<h3>{% trans %}News{% endtrans %}</h3>
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
{% endif %}
<section class="news_event">
<h4>{{ news.title }}</h4>
<p class="date">
......
{% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import user_profile_link %}
{% block title %}
{% if object %}
......@@ -9,6 +10,30 @@
{% endblock %}
{% block content %}
{% if 'preview' in request.POST.keys() %}
<section class="news_event">
<h4> <a href="#">{{ form.instance.title }}</a></h4>
<p class="date">
<span>{{ form.instance.dates.first().start_date|localtime|time(DATETIME_FORMAT) }}</span> -
<span>{{ form.instance.dates.first().end_date|localtime|time(DATETIME_FORMAT) }}</span>
</p>
<p><a href="#">{{ form.instance.club or "Club" }}</a></p>
<p>{{ form.instance.summary|markdown }}</p>
</section>
<hr>
<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>
<p>{{ form.instance.summary|markdown }}</p>
<p>{% trans %}Author: {% endtrans %} {{ user_profile_link(form.instance.author) }}</p>
</section>
{% endif %}
{% if object %}
<h2>{% trans %}Edit news{% endtrans %}</h2>
{% else %}
......@@ -20,10 +45,10 @@
{{ form.author }}
<p>{{ form.type.errors }}<label for="{{ form.type.name }}">{{ form.type.label }}</label>
<ul>
<li>Notice: Information, election result - no date</li>
<li>Evenement: punctual event, associated with one date</li>
<li>Weekly: recurrent event, associated with many dates (specify the first one, and a deadline)</li>
<li>Call: long time event, associated with a long date (election appliance, ...)</li>
<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>
......@@ -37,6 +62,7 @@
<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 %}
......
......@@ -125,6 +125,13 @@ class NewsEditView(CanEditMixin, UpdateView):
except: pass
return init
def post(self, request, *args, **kwargs):
form = self.get_form()
if form.is_valid() and not 'preview' in request.POST.keys():
return self.form_valid(form)
else:
return self.form_invalid(form)
def form_valid(self, form):
self.object = form.save()
if form.cleaned_data['automoderation'] and self.request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID):
......@@ -148,6 +155,14 @@ class NewsCreateView(CanCreateMixin, CreateView):
except: pass
return init
def post(self, request, *args, **kwargs):
form = self.get_form()
if form.is_valid() and not 'preview' in request.POST.keys():
return self.form_valid(form)
else:
self.object = form.instance
return self.form_invalid(form)
def form_valid(self, form):
self.object = form.save()
print(form.cleaned_data)
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-23 18:25+0100\n"
"POT-Creation-Date: 2016-12-23 19:35+0100\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -627,7 +627,7 @@ msgid "Edit operation"
msgstr "Éditer l'opération"
#: accounting/templates/accounting/operation_edit.jinja:41
#: com/templates/com/news_edit.jinja:40 core/templates/core/create.jinja:12
#: com/templates/com/news_edit.jinja:66 core/templates/core/create.jinja:12
#: core/templates/core/edit.jinja:7 core/templates/core/edit.jinja.py:15
#: core/templates/core/edit.jinja:20 core/templates/core/file_edit.jinja:8
#: core/templates/core/page_prop.jinja:8
......@@ -1002,7 +1002,7 @@ msgstr "page d'accueil"
#: com/models.py:22
msgid "Notice"
msgstr "Notification"
msgstr "Information"
#: com/models.py:23
msgid "Event"
......@@ -1057,6 +1057,11 @@ msgstr "date de début"
msgid "end_date"
msgstr "date de fin"
#: com/templates/com/macros.jinja:26 com/templates/com/news_detail.jinja:22
#: com/templates/com/news_edit.jinja:34
msgid "Author: "
msgstr "Auteur : "
#: com/templates/com/news_admin_list.jinja:5
msgid "News admin"
msgstr "Administration des nouvelles"
......@@ -1102,7 +1107,7 @@ msgid "News to moderate"
msgstr "Nouvelles à modérer"
#: com/templates/com/news_admin_list.jinja:72
#: com/templates/com/news_detail.jinja:28
#: com/templates/com/news_detail.jinja:26
#: core/templates/core/file_detail.jinja:65
#: core/templates/core/file_moderation.jinja:23
#: sas/templates/sas/moderation.jinja:17 sas/templates/sas/picture.jinja:114
......@@ -1113,26 +1118,49 @@ msgstr "Modérer"
msgid "Back to news"
msgstr "Retour aux nouvelles"
#: com/templates/com/news_detail.jinja:24
msgid "Author: "
msgstr "Auteur : "
#: com/templates/com/news_detail.jinja:26 sas/templates/sas/picture.jinja:82
#: com/templates/com/news_detail.jinja:24 sas/templates/sas/picture.jinja:82
msgid "Moderator: "
msgstr "Modérateur : "
#: com/templates/com/news_detail.jinja:31
#: com/templates/com/news_detail.jinja:29
msgid "Edit (will be remoderated)"
msgstr "Éditer (sera resoumise à modération)"
#: com/templates/com/news_edit.jinja:5 com/templates/com/news_edit.jinja:13
#: com/templates/com/news_edit.jinja:6 com/templates/com/news_edit.jinja:38
msgid "Edit news"
msgstr "Éditer la nouvelle"
#: com/templates/com/news_edit.jinja:7 com/templates/com/news_edit.jinja:15
#: com/templates/com/news_edit.jinja:8 com/templates/com/news_edit.jinja:40
msgid "Create news"
msgstr "Créer nouvelle"
#: com/templates/com/news_edit.jinja:48
msgid "Notice: Information, election result - no date"
msgstr "Information, resultat d'élection - sans date"
#: com/templates/com/news_edit.jinja:49
msgid "Event: punctual event, associated with one date"
msgstr "Événement : événement ponctuel associé à une date"
#: com/templates/com/news_edit.jinja:50
msgid ""
"Weekly: recurrent event, associated with many dates (specify the first one, "
"and a deadline)"
msgstr ""
"Hebdomadaire : événement récurrent, associé à plusieurs dates (spécifier la première, "
"ainsi que la date de fin)"
#: com/templates/com/news_edit.jinja:51
msgid ""
"Call: long time event, associated with a long date (election appliance, ...)"
msgstr ""
"Appel : événement de longue durée, associé à une longue date (candidature, concours, ...)"
#: com/templates/com/news_edit.jinja:65
#: core/templates/core/pagerev_edit.jinja:23
msgid "Preview"
msgstr "Prévisualiser"
#: com/templates/com/news_list.jinja:48
msgid "Events today and the next few days"
msgstr "Événement aujourd'hui et dans les prochains jours"
......@@ -2000,10 +2028,6 @@ msgstr "Propriétés de la page"
msgid "Edit page"
msgstr "Éditer la page"
#: core/templates/core/pagerev_edit.jinja:23
msgid "Preview"
msgstr "Prévisualiser"
#: core/templates/core/password_change.jinja:6
#, python-format
msgid "Change password for %(user)s"
......@@ -3448,4 +3472,3 @@ msgstr "Un utilisateur avec cette adresse email existe déjà"
msgid "You must either choose an existing user or create a new one properly"
msgstr ""
"Vous devez soit choisir un utilisateur existant, soit en créer un proprement"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment