<s> from django . core . urlresolvers import reverse <EOL> from django . core . urlresolvers import reverse_lazy <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon import tabs <EOL> from horizon . utils import memoized <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . volumes . snapshots import forms as vol_snapshot_forms <EOL> from openstack_dashboard . dashboards . project . volumes . snapshots import tables as vol_snapshot_tables <EOL> from openstack_dashboard . dashboards . project . volumes . snapshots import tabs as vol_snapshot_tabs <EOL> class UpdateView ( forms . ModalFormView ) : <EOL> form_class = vol_snapshot_forms . UpdateForm <EOL> form_id = "<STR_LIT>" <EOL> modal_header = _ ( "<STR_LIT>" ) <EOL> template_name = '<STR_LIT>' <EOL> submit_label = _ ( "<STR_LIT>" ) <EOL> submit_url = "<STR_LIT>" <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> page_title = _ ( "<STR_LIT>" ) <EOL> @ memoized . memoized_method <EOL> def get_object ( self ) : <EOL> snap_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . cinder . volume_snapshot_get ( self . request , <EOL> snap_id ) <EOL> except Exception : <EOL> msg = _ ( '<STR_LIT>' ) <EOL> url = reverse ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg , redirect = url ) <EOL> return self . _object <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UpdateView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . get_object ( ) <EOL> args = ( self . kwargs [ '<STR_LIT>' ] , ) <EOL> context [ '<STR_LIT>' ] = reverse ( self . submit_url , args = args ) <EOL> return context <EOL> def get_initial ( self ) : <EOL> snapshot = self . get_object ( ) <EOL> return { '<STR_LIT>' : self . kwargs [ "<STR_LIT>" ] , <EOL> '<STR_LIT:name>' : snapshot . name , <EOL> '<STR_LIT:description>' : snapshot . description } <EOL> class DetailView ( tabs . TabView ) : <EOL> tab_group_class = vol_snapshot_tabs . SnapshotDetailTabs <EOL> template_name = '<STR_LIT>' <EOL> page_title = "<STR_LIT>" <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( DetailView , self ) . get_context_data ( ** kwargs ) <EOL> snapshot = self . get_data ( ) <EOL> table = vol_snapshot_tables . VolumeSnapshotsTable ( self . request ) <EOL> context [ "<STR_LIT>" ] = snapshot <EOL> context [ "<STR_LIT:url>" ] = self . get_redirect_url ( ) <EOL> context [ "<STR_LIT>" ] = table . render_row_actions ( snapshot ) <EOL> return context <EOL> @ memoized . memoized_method <EOL> def get_data ( self ) : <EOL> try : <EOL> snapshot_id = self . kwargs [ '<STR_LIT>' ] <EOL> snapshot = api . cinder . volume_snapshot_get ( self . request , <EOL> snapshot_id ) <EOL> except Exception : <EOL> redirect = self . get_redirect_url ( ) <EOL> exceptions . handle ( self . request , <EOL> _ ( '<STR_LIT>' ) , <EOL> redirect = redirect ) <EOL> return snapshot <EOL> @ staticmethod <EOL> def get_redirect_url ( ) : <EOL> return reverse ( '<STR_LIT>' ) <EOL> def get_tabs ( self , request , * args , ** kwargs ) : <EOL> snapshot = self . get_data ( ) <EOL> return self . tab_group_class ( request , snapshot = snapshot , ** kwargs ) </s>
