From 00cf95423e06b47957834e9b686f62d244151c41 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 16 Dec 2017 04:01:39 +0100 Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20d'afficher=20un=20message=20?= =?UTF-8?q?global?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0025_generaloption_general_message.py | 20 +++++++++++++++++++ .../migrations/0026_auto_20171216_0401.py | 20 +++++++++++++++++++ preferences/models.py | 5 +++++ .../preferences/display_preferences.html | 4 ++++ re2o/context_processors.py | 4 ++++ 5 files changed, 53 insertions(+) create mode 100644 preferences/migrations/0025_generaloption_general_message.py create mode 100644 preferences/migrations/0026_auto_20171216_0401.py diff --git a/preferences/migrations/0025_generaloption_general_message.py b/preferences/migrations/0025_generaloption_general_message.py new file mode 100644 index 00000000..073ec44f --- /dev/null +++ b/preferences/migrations/0025_generaloption_general_message.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-12-16 02:38 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0024_optionaluser_all_can_create'), + ] + + operations = [ + migrations.AddField( + model_name='generaloption', + name='general_message', + field=models.TextField(default='', help_text='Message général affiché sur le site (maintenance, etc'), + ), + ] diff --git a/preferences/migrations/0026_auto_20171216_0401.py b/preferences/migrations/0026_auto_20171216_0401.py new file mode 100644 index 00000000..4adba4cd --- /dev/null +++ b/preferences/migrations/0026_auto_20171216_0401.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-12-16 03:01 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0025_generaloption_general_message'), + ] + + operations = [ + migrations.AlterField( + model_name='generaloption', + name='general_message', + field=models.TextField(blank=True, default='', help_text='Message général affiché sur le site (maintenance, etc'), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index 6a793a24..2e803b66 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -102,6 +102,11 @@ class GeneralOption(models.Model): temps où les liens sont valides""" PRETTY_NAME = "Options générales" + general_message = models.TextField( + default="", + blank=True, + help_text="Message général affiché sur le site (maintenance, etc" + ) search_display_page = models.IntegerField(default=15) pagination_number = models.IntegerField(default=25) pagination_large_number = models.IntegerField(default=8) diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index 4858e414..ad807155 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -131,6 +131,10 @@ with this program; if not, write to the Free Software Foundation, Inc., Temps avant expiration du lien de reinitialisation de mot de passe (en heures) {{ generaloptions.req_expire_hrs }} + + Message global affiché sur le site + {{ generaloptions.general_message }} +

Données de l'association

{% if is_bureau %} diff --git a/re2o/context_processors.py b/re2o/context_processors.py index e562a347..0f9ea3fc 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -23,6 +23,7 @@ from __future__ import unicode_literals +from django.contrib import messages from preferences.models import GeneralOption, OptionalMachine @@ -33,6 +34,9 @@ def context_user(request): general_options, _created = GeneralOption.objects.get_or_create() machine_options, _created = OptionalMachine.objects.get_or_create() user = request.user + global_message = general_options.general_message + if global_message: + messages.warning(request, global_message) if user.is_authenticated(): interfaces = user.user_interfaces() is_cableur = user.is_cableur