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 @@ ...@@ -9,8 +9,6 @@
{% block content %} {% block content %}
<p><a href="{{ url('com:news_list') }}">{% trans %}Back to news{% endtrans %}</a></p> <p><a href="{{ url('com:news_list') }}">{% trans %}Back to news{% endtrans %}</a></p>
<h3>{% trans %}News{% endtrans %}</h3> <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"> <section class="news_event">
<h4>{{ news.title }}</h4> <h4>{{ news.title }}</h4>
<p class="date"> <p class="date">
......
{% extends "core/base.jinja" %} {% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import user_profile_link %}
{% block title %} {% block title %}
{% if object %} {% if object %}
...@@ -9,6 +10,30 @@ ...@@ -9,6 +10,30 @@
{% endblock %} {% endblock %}
{% block content %} {% 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 %} {% if object %}
<h2>{% trans %}Edit news{% endtrans %}</h2> <h2>{% trans %}Edit news{% endtrans %}</h2>
{% else %} {% else %}
...@@ -20,10 +45,10 @@ ...@@ -20,10 +45,10 @@
{{ form.author }} {{ form.author }}
<p>{{ form.type.errors }}<label for="{{ form.type.name }}">{{ form.type.label }}</label> <p>{{ form.type.errors }}<label for="{{ form.type.name }}">{{ form.type.label }}</label>
<ul> <ul>
<li>Notice: Information, election result - no date</li> <li>{% trans %}Notice: Information, election result - no date{% endtrans %}</li>
<li>Evenement: punctual event, associated with one date</li> <li>{% trans %}Event: punctual event, associated with one date{% endtrans %}</li>
<li>Weekly: recurrent event, associated with many dates (specify the first one, and a deadline)</li> <li>{% trans %}Weekly: recurrent event, associated with many dates (specify the first one, and a deadline){% endtrans %}</li>
<li>Call: long time event, associated with a long date (election appliance, ...)</li> <li>{% trans %}Call: long time event, associated with a long date (election appliance, ...){% endtrans %}</li>
</ul> </ul>
{{ form.type }}</p> {{ 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.start_date.errors }}<label for="{{ form.start_date.name }}">{{ form.start_date.label }}</label> {{ form.start_date }}</p>
...@@ -37,6 +62,7 @@ ...@@ -37,6 +62,7 @@
<p>{{ form.automoderation.errors }}<label for="{{ form.automoderation.name }}">{{ form.automoderation.label }}</label> <p>{{ form.automoderation.errors }}<label for="{{ form.automoderation.name }}">{{ form.automoderation.label }}</label>
{{ form.automoderation }}</p> {{ form.automoderation }}</p>
{% endif %} {% endif %}
<p><input type="submit" name="preview" value="{% trans %}Preview{% endtrans %}" /></p>
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form> </form>
{% endblock %} {% endblock %}
......
...@@ -125,6 +125,13 @@ class NewsEditView(CanEditMixin, UpdateView): ...@@ -125,6 +125,13 @@ class NewsEditView(CanEditMixin, UpdateView):
except: pass except: pass
return init 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): def form_valid(self, form):
self.object = form.save() self.object = form.save()
if form.cleaned_data['automoderation'] and self.request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID): 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): ...@@ -148,6 +155,14 @@ class NewsCreateView(CanCreateMixin, CreateView):
except: pass except: pass
return init 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): def form_valid(self, form):
self.object = form.save() self.object = form.save()
print(form.cleaned_data) print(form.cleaned_data)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "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" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
...@@ -627,7 +627,7 @@ msgid "Edit operation" ...@@ -627,7 +627,7 @@ msgid "Edit operation"
msgstr "Éditer l'opération" msgstr "Éditer l'opération"
#: accounting/templates/accounting/operation_edit.jinja:41 #: 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:7 core/templates/core/edit.jinja.py:15
#: core/templates/core/edit.jinja:20 core/templates/core/file_edit.jinja:8 #: core/templates/core/edit.jinja:20 core/templates/core/file_edit.jinja:8
#: core/templates/core/page_prop.jinja:8 #: core/templates/core/page_prop.jinja:8
...@@ -1002,7 +1002,7 @@ msgstr "page d'accueil" ...@@ -1002,7 +1002,7 @@ msgstr "page d'accueil"
#: com/models.py:22 #: com/models.py:22
msgid "Notice" msgid "Notice"
msgstr "Notification" msgstr "Information"
#: com/models.py:23 #: com/models.py:23
msgid "Event" msgid "Event"
...@@ -1057,6 +1057,11 @@ msgstr "date de début" ...@@ -1057,6 +1057,11 @@ msgstr "date de début"
msgid "end_date" msgid "end_date"
msgstr "date de fin" 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 #: com/templates/com/news_admin_list.jinja:5
msgid "News admin" msgid "News admin"
msgstr "Administration des nouvelles" msgstr "Administration des nouvelles"
...@@ -1102,7 +1107,7 @@ msgid "News to moderate" ...@@ -1102,7 +1107,7 @@ msgid "News to moderate"
msgstr "Nouvelles à modérer" msgstr "Nouvelles à modérer"
#: com/templates/com/news_admin_list.jinja:72 #: 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_detail.jinja:65
#: core/templates/core/file_moderation.jinja:23 #: core/templates/core/file_moderation.jinja:23
#: sas/templates/sas/moderation.jinja:17 sas/templates/sas/picture.jinja:114 #: sas/templates/sas/moderation.jinja:17 sas/templates/sas/picture.jinja:114
...@@ -1113,26 +1118,49 @@ msgstr "Modérer" ...@@ -1113,26 +1118,49 @@ msgstr "Modérer"
msgid "Back to news" msgid "Back to news"
msgstr "Retour aux nouvelles" msgstr "Retour aux nouvelles"
#: com/templates/com/news_detail.jinja:24 #: com/templates/com/news_detail.jinja:24 sas/templates/sas/picture.jinja:82
msgid "Author: "
msgstr "Auteur : "
#: com/templates/com/news_detail.jinja:26 sas/templates/sas/picture.jinja:82
msgid "Moderator: " msgid "Moderator: "
msgstr "Modérateur : " msgstr "Modérateur : "
#: com/templates/com/news_detail.jinja:31 #: com/templates/com/news_detail.jinja:29
msgid "Edit (will be remoderated)" msgid "Edit (will be remoderated)"
msgstr "Éditer (sera resoumise à modération)" 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" msgid "Edit news"
msgstr "Éditer la nouvelle" 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" msgid "Create news"
msgstr "Créer nouvelle" 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 #: com/templates/com/news_list.jinja:48
msgid "Events today and the next few days" msgid "Events today and the next few days"
msgstr "Événement aujourd'hui et dans les prochains jours" msgstr "Événement aujourd'hui et dans les prochains jours"
...@@ -2000,10 +2028,6 @@ msgstr "Propriétés de la page" ...@@ -2000,10 +2028,6 @@ msgstr "Propriétés de la page"
msgid "Edit page" msgid "Edit page"
msgstr "Éditer la page" msgstr "Éditer la page"
#: core/templates/core/pagerev_edit.jinja:23
msgid "Preview"
msgstr "Prévisualiser"
#: core/templates/core/password_change.jinja:6 #: core/templates/core/password_change.jinja:6
#, python-format #, python-format
msgid "Change password for %(user)s" msgid "Change password for %(user)s"
...@@ -3448,4 +3472,3 @@ msgstr "Un utilisateur avec cette adresse email existe déjà" ...@@ -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" msgid "You must either choose an existing user or create a new one properly"
msgstr "" msgstr ""
"Vous devez soit choisir un utilisateur existant, soit en créer un proprement" "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