Commit 80708e87 authored by Charlie Jacomme's avatar Charlie Jacomme Committed by chirac
Browse files

Fix messages for usage in API

parent 771e8cc3
...@@ -26,7 +26,7 @@ from __future__ import unicode_literals ...@@ -26,7 +26,7 @@ from __future__ import unicode_literals
import datetime import datetime
from django.contrib import messages from django.contrib import messages
from django.http import HttpRequest
from preferences.models import GeneralOption, OptionalMachine from preferences.models import GeneralOption, OptionalMachine
from django.utils.translation import get_language from django.utils.translation import get_language
...@@ -40,7 +40,10 @@ def context_user(request): ...@@ -40,7 +40,10 @@ def context_user(request):
else: else:
global_message = GeneralOption.get_cached_value('general_message_en') global_message = GeneralOption.get_cached_value('general_message_en')
if global_message: if global_message:
messages.warning(request, global_message) if isinstance(request, HttpRequest):
messages.warning(request, global_message)
else:
messages.warning(request._request, global_message)
if user.is_authenticated(): if user.is_authenticated():
interfaces = user.user_interfaces() interfaces = user.user_interfaces()
else: else:
......
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