<s> """<STR_LIT>""" <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from horizon import exceptions <EOL> from horizon import tables as horizon_tables <EOL> from horizon . utils import filters <EOL> from horizon import views as horizon_views <EOL> from horizon import workflows as horizon_workflows <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . database_backups import tables <EOL> from openstack_dashboard . dashboards . project . database_backups import workflows <EOL> class IndexView ( horizon_tables . DataTableView ) : <EOL> table_class = tables . BackupsTable <EOL> template_name = '<STR_LIT>' <EOL> def _get_extra_data ( self , backup ) : <EOL> """<STR_LIT>""" <EOL> instance_id = backup . instance_id <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _instances = { } <EOL> instance = self . _instances . get ( instance_id ) <EOL> if instance is None : <EOL> try : <EOL> instance = api . trove . instance_get ( self . request , instance_id ) <EOL> except Exception : <EOL> instance = _ ( '<STR_LIT>' ) <EOL> backup . instance = instance <EOL> return backup <EOL> def get_data ( self ) : <EOL> try : <EOL> backups = api . trove . backup_list ( self . request ) <EOL> backups = map ( self . _get_extra_data , backups ) <EOL> except Exception : <EOL> backups = [ ] <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg ) <EOL> return backups <EOL> class BackupView ( horizon_workflows . WorkflowView ) : <EOL> workflow_class = workflows . CreateBackup <EOL> template_name = "<STR_LIT>" <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( BackupView , self ) . get_context_data ( ** kwargs ) <EOL> context [ "<STR_LIT>" ] = kwargs . get ( "<STR_LIT>" ) <EOL> self . _instance = context [ '<STR_LIT>' ] <EOL> return context <EOL> class DetailView ( horizon_views . APIView ) : <EOL> template_name = "<STR_LIT>" <EOL> def get_data ( self , request , context , * args , ** kwargs ) : <EOL> backup_id = kwargs . get ( "<STR_LIT>" ) <EOL> try : <EOL> backup = api . trove . backup_get ( request , backup_id ) <EOL> created_at = filters . parse_isotime ( backup . created ) <EOL> updated_at = filters . parse_isotime ( backup . updated ) <EOL> backup . duration = updated_at - created_at <EOL> except Exception : <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> msg = _ ( '<STR_LIT>' ) % backup_id <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> try : <EOL> if ( hasattr ( backup , '<STR_LIT>' ) and backup . parent_id is not None ) : <EOL> backup . parent = api . trove . backup_get ( request , backup . parent_id ) <EOL> except Exception : <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> msg = ( _ ( '<STR_LIT>' ) <EOL> % backup . parent_id ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> try : <EOL> instance = api . trove . instance_get ( request , backup . instance_id ) <EOL> except Exception : <EOL> instance = None <EOL> context [ '<STR_LIT>' ] = backup <EOL> context [ '<STR_LIT>' ] = instance <EOL> context [ '<STR_LIT>' ] = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) % { '<STR_LIT>' : <EOL> backup . name } <EOL> return context </s>
