<s> """<STR_LIT>""" <EOL> 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 . utils import filters <EOL> from openstack_dashboard . dashboards . project . images . images import forms as project_forms <EOL> from openstack_dashboard . dashboards . project . images . images import tables as project_tables <EOL> from openstack_dashboard . dashboards . project . images . images import tabs as project_tabs <EOL> class CreateView ( forms . ModalFormView ) : <EOL> form_class = project_forms . CreateImageForm <EOL> form_id = "<STR_LIT>" <EOL> modal_header = _ ( "<STR_LIT>" ) <EOL> submit_label = _ ( "<STR_LIT>" ) <EOL> submit_url = reverse_lazy ( '<STR_LIT>' ) <EOL> template_name = '<STR_LIT>' <EOL> context_object_name = '<STR_LIT:image>' <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> page_title = _ ( "<STR_LIT>" ) <EOL> def get_initial ( self ) : <EOL> initial = { } <EOL> for name in [ <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT:description>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] : <EOL> tmp = self . request . GET . get ( name ) <EOL> if tmp : <EOL> initial [ name ] = tmp <EOL> return initial <EOL> class UpdateView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateImageForm <EOL> form_id = "<STR_LIT>" <EOL> modal_header = _ ( "<STR_LIT>" ) <EOL> submit_label = _ ( "<STR_LIT>" ) <EOL> submit_url = "<STR_LIT>" <EOL> template_name = '<STR_LIT>' <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> page_title = _ ( "<STR_LIT>" ) <EOL> @ memoized . memoized_method <EOL> def get_object ( self ) : <EOL> try : <EOL> return api . glance . image_get ( self . request , self . kwargs [ '<STR_LIT>' ] ) <EOL> except Exception : <EOL> msg = _ ( '<STR_LIT>' ) <EOL> url = reverse ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg , redirect = url ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UpdateView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT:image>' ] = 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> image = self . get_object ( ) <EOL> properties = getattr ( image , '<STR_LIT>' , { } ) <EOL> data = { '<STR_LIT>' : self . kwargs [ '<STR_LIT>' ] , <EOL> '<STR_LIT:name>' : getattr ( image , '<STR_LIT:name>' , None ) or image . id , <EOL> '<STR_LIT:description>' : properties . get ( '<STR_LIT:description>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : properties . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : properties . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : properties . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : getattr ( image , '<STR_LIT>' , None ) , <EOL> '<STR_LIT>' : getattr ( image , '<STR_LIT>' , None ) , <EOL> '<STR_LIT>' : getattr ( image , '<STR_LIT>' , None ) , <EOL> '<STR_LIT>' : getattr ( image , '<STR_LIT>' , None ) } <EOL> disk_format = getattr ( image , '<STR_LIT>' , None ) <EOL> if ( disk_format == '<STR_LIT>' and <EOL> getattr ( image , '<STR_LIT>' ) == '<STR_LIT>' ) : <EOL> disk_format = '<STR_LIT>' <EOL> data [ '<STR_LIT>' ] = disk_format <EOL> return data <EOL> class DetailView ( tabs . TabView ) : <EOL> tab_group_class = project_tabs . ImageDetailTabs <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> image = self . get_data ( ) <EOL> table = project_tables . ImagesTable ( self . request ) <EOL> context [ "<STR_LIT:image>" ] = image <EOL> context [ "<STR_LIT:url>" ] = self . get_redirect_url ( ) <EOL> context [ "<STR_LIT>" ] = table . render_row_actions ( image ) <EOL> choices = project_tables . ImagesTable . STATUS_DISPLAY_CHOICES <EOL> image . status_label = filters . get_display_label ( choices , image . status ) <EOL> return context <EOL> @ staticmethod <EOL> def get_redirect_url ( ) : <EOL> return reverse_lazy ( '<STR_LIT>' ) <EOL> @ memoized . memoized_method <EOL> def get_data ( self ) : <EOL> try : <EOL> return api . glance . image_get ( self . request , self . kwargs [ '<STR_LIT>' ] ) <EOL> except Exception : <EOL> exceptions . handle ( self . request , <EOL> _ ( '<STR_LIT>' ) , <EOL> redirect = self . get_redirect_url ( ) ) <EOL> def get_tabs ( self , request , * args , ** kwargs ) : <EOL> image = self . get_data ( ) <EOL> return self . tab_group_class ( request , image = image , ** kwargs ) </s>
