Used ternary operator to simplify contrib.messages.api.

This commit is contained in:
GhostThrone 2015-09-25 13:02:23 -05:00 committed by Tim Graham
parent de99f558d8
commit 829e33f67f
1 changed files with 2 additions and 8 deletions

View File

@ -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