From 31f08d84654bfc658c6ca8ed0057a3fd572db733 Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Tue, 20 Oct 2020 12:32:50 +0200 Subject: [PATCH] Check to avoid multiple messages --- re2o/context_processors.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index b6c54e22..6b61e2a0 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -26,6 +26,7 @@ from __future__ import unicode_literals import datetime from django.contrib import messages +from django.contrib.messages import get_messages from django.http import HttpRequest from preferences.models import GeneralOption, OptionalMachine from django.utils.translation import get_language @@ -47,9 +48,11 @@ def context_user(request): global_message = GeneralOption.get_cached_value("general_message_en") if global_message: if isinstance(request, HttpRequest): - messages.warning(request, global_message) + if global_message not in [msg.message for msg in get_messages(request)]: + messages.warning(request, global_message) else: - messages.warning(request._request, global_message) + if global_message not in [msg.message for msg in get_messages(request._request)]: + messages.warning(request._request, global_message) if user.is_authenticated(): interfaces = user.user_interfaces() else: