<s> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon . utils import memoized <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . networks . ports import views as project_views <EOL> from openstack_dashboard . dashboards . admin . networks . ports import forms as project_forms <EOL> class CreateView ( forms . ModalFormView ) : <EOL> form_class = project_forms . CreatePort <EOL> template_name = '<STR_LIT>' <EOL> success_url = '<STR_LIT>' <EOL> failure_url = '<STR_LIT>' <EOL> def get_success_url ( self ) : <EOL> return reverse ( self . success_url , <EOL> args = ( self . kwargs [ '<STR_LIT>' ] , ) ) <EOL> @ memoized . memoized_method <EOL> def get_object ( self ) : <EOL> try : <EOL> network_id = self . kwargs [ "<STR_LIT>" ] <EOL> return api . neutron . network_get ( self . request , network_id ) <EOL> except Exception : <EOL> redirect = reverse ( self . failure_url , <EOL> args = ( self . kwargs [ '<STR_LIT>' ] , ) ) <EOL> msg = _ ( "<STR_LIT>" ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( CreateView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . get_object ( ) <EOL> return context <EOL> def get_initial ( self ) : <EOL> network = self . get_object ( ) <EOL> return { "<STR_LIT>" : self . kwargs [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : network . name } <EOL> class UpdateView ( project_views . UpdateView ) : <EOL> form_class = project_forms . UpdatePort <EOL> template_name = '<STR_LIT>' <EOL> context_object_name = '<STR_LIT:port>' <EOL> success_url = '<STR_LIT>' </s>
