<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 . 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> template_name = '<STR_LIT>' <EOL> context_object_name = '<STR_LIT:image>' <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> class UpdateView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateImageForm <EOL> template_name = '<STR_LIT>' <EOL> success_url = reverse_lazy ( "<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> return context <EOL> def get_initial ( self ) : <EOL> image = self . get_object ( ) <EOL> properties = getattr ( image , '<STR_LIT>' , { } ) <EOL> return { '<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> '<STR_LIT>' : getattr ( image , '<STR_LIT>' , None ) } <EOL> class DetailView ( tabs . TabView ) : <EOL> tab_group_class = project_tabs . ImageDetailTabs <EOL> template_name = '<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> context [ "<STR_LIT>" ] = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) % { '<STR_LIT>' : <EOL> image . name } <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>
