Commit cd13c524 authored by Maxime Bombar's avatar Maxime Bombar

Allows to display a French or English general message based on user's language choice.

parent e0f82c7d
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-08-11 13:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0047_mailcontact'),
]
operations = [
migrations.RemoveField(
model_name='generaloption',
name='general_message',
),
migrations.AddField(
model_name='generaloption',
name='general_message_en',
field=models.TextField(blank=True, default='', help_text='General message displayed on the English version of the website.'),
),
migrations.AddField(
model_name='generaloption',
name='general_message_fr',
field=models.TextField(blank=True, default='', help_text='Message général affiché sur le site (maintenance, etc)'),
),
]
......@@ -217,10 +217,15 @@ class GeneralOption(AclMixin, PreferencesModel):
temps où les liens sont valides"""
PRETTY_NAME = "Options générales"
general_message = models.TextField(
general_message_fr = models.TextField(
default="",
blank=True,
help_text="Message général affiché sur le site (maintenance, etc"
help_text="Message général affiché sur le site (maintenance, etc)"
)
general_message_en = models.TextField(
default="",
blank=True,
help_text="General message displayed on the English version of the website."
)
search_display_page = models.IntegerField(default=15)
pagination_number = models.IntegerField(default=25)
......
......@@ -28,13 +28,17 @@ import datetime
from django.contrib import messages
from preferences.models import GeneralOption, OptionalMachine
from django.utils.translation import get_language
def context_user(request):
"""Fonction de context lorsqu'un user est logué (ou non),
renvoie les infos sur l'user, la liste de ses droits, ses machines"""
user = request.user
global_message = GeneralOption.get_cached_value('general_message')
if get_language()=='fr':
global_message = GeneralOption.get_cached_value('general_message_fr')
else:
global_message = GeneralOption.get_cached_value('general_message_en')
if global_message:
messages.warning(request, global_message)
if user.is_authenticated():
......
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