Fix warnings on py27 environment

AttributeError exceptions were being hit due to
share_group_id and revert_to_snapshot_support
attributes trying to be accessed directly
when they are not always available.

Change-Id: Ic0169bfa4c6b2e747eff1b4cf63b473e58aadda6
This commit is contained in:
Victoria Martinez de la Cruz 2018-03-22 17:39:55 -03:00
parent 2203bf4134
commit 95c39e5094
1 changed files with 3 additions and 2 deletions

View File

@ -167,7 +167,7 @@ class RevertShare(tables.LinkAction):
def allowed(self, request, share=None):
return (
share.revert_to_snapshot_support and
getattr(share, 'revert_to_snapshot_support', False) and
share.status.lower() == "available"
)
@ -255,7 +255,8 @@ class SharesTableBase(tables.DataTable):
return obj.name or obj.id
def get_share_group_link(share):
if features.is_share_groups_enabled() and share.share_group_id:
if (features.is_share_groups_enabled() and
getattr(share, 'share_group_id', None)):
return reverse(
"horizon:project:share_groups:detail",
args=(share.share_group_id,))