Used ternary operator to simplify contrib.messages.api.
This commit is contained in:
parent
de99f558d8
commit
829e33f67f
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue