From 829e33f67f8b3fa8ccade46f14482f4a6ddd7b9d Mon Sep 17 00:00:00 2001 From: GhostThrone Date: Fri, 25 Sep 2015 13:02:23 -0500 Subject: [PATCH] Used ternary operator to simplify contrib.messages.api. --- django/contrib/messages/api.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/django/contrib/messages/api.py b/django/contrib/messages/api.py index 248e0f0e64..8b6b96f96a 100644 --- a/django/contrib/messages/api.py +++ b/django/contrib/messages/api.py @@ -33,10 +33,7 @@ def get_messages(request): Returns the message storage on the request if it exists, otherwise returns an empty list. """ - if hasattr(request, '_messages'): - return request._messages - else: - return [] + return request._messages if hasattr(request, '_messages') else [] def get_level(request): @@ -46,10 +43,7 @@ def get_level(request): The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used. """ - if hasattr(request, '_messages'): - storage = request._messages - else: - storage = default_storage(request) + storage = request._messages if hasattr(request, '_messages') else default_storage(request) return storage.level