Fixing potential attribute access on None

Specifically when writing tests, the nav method in the settings
dashboard.py file can potentially attempt to access slug on None.

Closes-bug: #1291050

Change-Id: I6df58d26f5df71ac7c605c5d77b9aa9d8d811956
This commit is contained in:
David Lyle 2014-03-11 15:04:52 -06:00
parent 6de70303cf
commit ab3cdfd1c9

View File

@ -27,7 +27,8 @@ class Settings(horizon.Dashboard):
default_panel = 'user'
def nav(self, context):
if context['request'].horizon.get('dashboard', None).slug == self.slug:
dash = context['request'].horizon.get('dashboard', None)
if dash and dash.slug == self.slug:
return True
return False