mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Allows to display a French or English general message based on user's language choice.
This commit is contained in:
parent
e0f82c7d6d
commit
cd13c5240a
3 changed files with 41 additions and 3 deletions
29
preferences/migrations/0048_auto_20180811_1515.py
Normal file
29
preferences/migrations/0048_auto_20180811_1515.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- 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():
|
||||
|
|
Loading…
Reference in a new issue