Remove Restore Backup Action For Non-Completed

the "restore backup" action is incorrectly shown for an uncompleted
database backup in the database backups table. now, only if the
backup is completed, will the action/button appear.

in addition, uncompleted backups are now excluded from the dropdown
in the create-instance workflow.

Change-Id: I6e4962eaf5eeee18d85cace384e0879dd33056e2
Closes-Bug: #1268277
This commit is contained in:
amcrn 2014-01-16 01:42:28 -08:00
parent e578ec1a33
commit 27e1fc9f9b
2 changed files with 5 additions and 1 deletions

View File

@ -47,6 +47,9 @@ class RestoreLink(tables.LinkAction):
url = "horizon:project:databases:launch"
classes = ("btn-launch", "ajax-modal")
def allowed(self, request, backup=None):
return backup.status == 'COMPLETED'
def get_link_url(self, datum):
url = reverse(self.url)
return url + '?backup=%s' % datum.id

View File

@ -123,7 +123,8 @@ class RestoreAction(workflows.Action):
empty = [('', '-')]
try:
backups = api.trove.backup_list(request)
backup_list = [(b.id, b.name) for b in backups]
backup_list = [(b.id, b.name) for b in backups
if b.status == 'COMPLETED']
except Exception:
backup_list = []
return empty + backup_list