Avoid attr error on database backup page
For some reason (and I genuinely do not have a clue why) some database-backups don't appear to have an instance attribute. This causes a problem when loading the table data, as the db_name helper-function raises an AttributeError. It appears that we're prepared for obj.instance.name to not exist, but if obj.instance doesn't exist, then we raise the attribute error. The solution is to return the obj.instance_id in both cases. Change-Id: I77a30e4aeb97744aa14151eca0b4c011476fb08d Closes-Bug: 1312235
This commit is contained in:
parent
84ca8a9da8
commit
efcf490cf3
|
@ -108,14 +108,14 @@ def db_link(obj):
|
|||
|
||||
|
||||
def db_name(obj):
|
||||
if hasattr(obj.instance, 'name'):
|
||||
return obj.instance.name
|
||||
return obj.instance_id
|
||||
if not hasattr(obj, 'instance') or not hasattr(obj.instance, 'name'):
|
||||
return obj.instance_id
|
||||
return obj.instance.name
|
||||
|
||||
|
||||
class BackupsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
link=("horizon:project:database_backups:detail"),
|
||||
link="horizon:project:database_backups:detail",
|
||||
verbose_name=_("Name"))
|
||||
created = tables.Column("created", verbose_name=_("Created At"),
|
||||
filters=[filters.parse_isotime])
|
||||
|
|
Loading…
Reference in New Issue