<s> import threading <EOL> from cgi import escape as html_escape <EOL> from core . models import * <EOL> from core . models import Site <EOL> from django import forms <EOL> from django . contrib import admin , messages <EOL> from django . contrib . admin . widgets import ( AdminTextareaWidget , <EOL> FilteredSelectMultiple ) <EOL> from django . contrib . auth . admin import UserAdmin <EOL> from django . contrib . auth . forms import ( AdminPasswordChangeForm , <EOL> ReadOnlyPasswordHashField ) <EOL> from django . contrib . auth . models import Group <EOL> from django . contrib . auth . signals import user_logged_in <EOL> from django . contrib . contenttypes import generic <EOL> from django . core . exceptions import PermissionDenied , ValidationError <EOL> from django . core . urlresolvers import NoReverseMatch , resolve , reverse <EOL> from django . forms . utils import flatatt , to_current_timezone <EOL> from django . utils import timezone <EOL> from django . utils . encoding import force_text , python_2_unicode_compatible <EOL> from django . utils . html import conditional_escape , format_html <EOL> from django . utils . safestring import mark_safe <EOL> from django . utils . text import capfirst <EOL> from openstack . manager import OpenStackManager <EOL> from suit . widgets import LinkedSelect <EOL> _thread_locals = threading . local ( ) <EOL> ICON_URLS = { "<STR_LIT:success>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:error>" : "<STR_LIT>" } <EOL> def backend_icon ( obj ) : <EOL> ( icon , tooltip ) = obj . get_backend_icon ( ) <EOL> icon_url = ICON_URLS . get ( icon , "<STR_LIT>" ) <EOL> ( exponent , last_success , last_failure , failures ) = obj . get_backend_details ( ) <EOL> if ( obj . pk ) : <EOL> script = """<STR_LIT>""" % ( obj . pk , obj . pk ) <EOL> div = """<STR_LIT>""" % ( obj . pk , exponent , last_success , failures , last_failure ) <EOL> a = '<STR_LIT>' % obj . pk <EOL> astop = '<STR_LIT>' <EOL> else : <EOL> div = '<STR_LIT>' <EOL> script = '<STR_LIT>' <EOL> a = '<STR_LIT>' <EOL> astop = '<STR_LIT>' <EOL> if tooltip : <EOL> return '<STR_LIT>' % ( script , div , tooltip , a , icon_url , astop ) <EOL> else : <EOL> return '<STR_LIT>' % icon_url <EOL> def backend_text ( obj ) : <EOL> ( icon , tooltip ) = obj . get_backend_icon ( ) <EOL> icon_url = ICON_URLS . get ( icon , "<STR_LIT>" ) <EOL> return '<STR_LIT>' % ( icon_url , tooltip ) <EOL> class UploadTextareaWidget ( AdminTextareaWidget ) : <EOL> def render ( self , name , value , attrs = None ) : <EOL> if value is None : <EOL> value = '<STR_LIT>' <EOL> final_attrs = self . build_attrs ( attrs , name = name ) <EOL> return format_html ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> attrs [ "<STR_LIT:id>" ] , attrs [ "<STR_LIT:id>" ] , attrs [ "<STR_LIT:id>" ] ) , <EOL> flatatt ( final_attrs ) , <EOL> force_text ( value ) ) <EOL> class SliderWidget ( forms . HiddenInput ) : <EOL> def render ( self , name , value , attrs = None ) : <EOL> if value is None : <EOL> value = '<STR_LIT:0>' <EOL> final_attrs = self . build_attrs ( attrs , name = name ) <EOL> attrs = attrs or attrs [ : ] <EOL> attrs [ "<STR_LIT:name>" ] = name <EOL> attrs [ "<STR_LIT:value>" ] = value <EOL> html = """<STR_LIT>""" % attrs <EOL> html = html . replace ( "<STR_LIT:{>" , "<STR_LIT>" ) . replace ( "<STR_LIT:}>" , "<STR_LIT>" ) <EOL> return format_html ( html , <EOL> flatatt ( final_attrs ) , <EOL> force_text ( value ) ) <EOL> class PlainTextWidget ( forms . HiddenInput ) : <EOL> input_type = '<STR_LIT>' <EOL> def render ( self , name , value , attrs = None ) : <EOL> if value is None : <EOL> value = '<STR_LIT>' <EOL> return mark_safe ( str ( value ) + super ( PlainTextWidget , self ) . render ( name , value , attrs ) ) <EOL> class XOSAdminMixin ( object ) : <EOL> def has_add_permission ( self , request , obj = None ) : <EOL> return ( not self . __user_is_readonly ( request ) ) <EOL> def has_delete_permission ( self , request , obj = None ) : <EOL> return ( not self . __user_is_readonly ( request ) ) <EOL> def save_model ( self , request , obj , form , change ) : <EOL> if self . __user_is_readonly ( request ) : <EOL> raise PermissionDenied <EOL> if hasattr ( obj , "<STR_LIT>" ) : <EOL> obj . backend_register = "<STR_LIT:{}>" <EOL> obj . caller = request . user <EOL> obj . save_by_user ( request . user ) <EOL> def delete_model ( self , request , obj ) : <EOL> obj . delete_by_user ( request . user ) <EOL> def save_formset ( self , request , form , formset , change ) : <EOL> instances = formset . save ( commit = False ) <EOL> for instance in instances : <EOL> instance . caller = request . user <EOL> instance . save_by_user ( request . user ) <EOL> try : <EOL> forms_to_delete = formset . deleted_forms <EOL> except AttributeError : <EOL> forms_to_delete = [ ] <EOL> if formset . initial_forms : <EOL> for form in formset . initial_forms : <EOL> obj = form . instance <EOL> if form in forms_to_delete : <EOL> if obj . pk is None : <EOL> continue <EOL> formset . deleted_objects . append ( obj ) <EOL> obj . delete ( ) <EOL> formset . save_m2m ( ) <EOL> def get_actions ( self , request ) : <EOL> actions = super ( XOSAdminMixin , self ) . get_actions ( request ) <EOL> if self . __user_is_readonly ( request ) : <EOL> if '<STR_LIT>' in actions : <EOL> del actions [ '<STR_LIT>' ] <EOL> return actions <EOL> def url_for_model_changelist ( self , request , model ) : <EOL> return reverse ( '<STR_LIT>' % ( model . _meta . app_label , model . _meta . model_name ) , current_app = model . _meta . app_label ) <EOL> def add_extra_context ( self , request , extra_context ) : <EOL> extra_context [ "<STR_LIT>" ] = getattr ( <EOL> self , "<STR_LIT>" , None ) <EOL> extra_context [ "<STR_LIT>" ] = getattr ( <EOL> self , "<STR_LIT>" , None ) <EOL> extra_context [ "<STR_LIT>" ] = getattr ( <EOL> self , "<STR_LIT>" , None ) <EOL> if getattr ( self , "<STR_LIT>" , False ) : <EOL> admins = [ ] <EOL> for model , model_admin in admin . site . _registry . items ( ) : <EOL> if model == self . model : <EOL> continue <EOL> if model . _meta . app_label == self . model . _meta . app_label : <EOL> info = { "<STR_LIT>" : model . _meta . app_label , <EOL> "<STR_LIT>" : model . _meta . model_name , <EOL> "<STR_LIT:name>" : capfirst ( model . _meta . verbose_name_plural ) , <EOL> "<STR_LIT:url>" : self . url_for_model_changelist ( request , model ) } <EOL> admins . append ( info ) <EOL> extra_context [ "<STR_LIT>" ] = admins <EOL> def change_view ( self , request , object_id , extra_context = None ) : <EOL> extra_context = extra_context or { } <EOL> if self . __user_is_readonly ( request ) : <EOL> if not hasattr ( self , "<STR_LIT>" ) : <EOL> self . readonly_save = self . readonly_fields <EOL> self . inlines_save = self . inlines <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . readonly_fields = self . user_readonly_fields <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . inlines = self . user_readonly_inlines <EOL> else : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . readonly_fields = self . readonly_save <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . inlines = self . inlines_save <EOL> self . add_extra_context ( request , extra_context ) <EOL> try : <EOL> return super ( XOSAdminMixin , self ) . change_view ( request , object_id , extra_context = extra_context ) <EOL> except PermissionDenied : <EOL> pass <EOL> except ValidationError as e : <EOL> if ( e . params is None ) : <EOL> request . method = '<STR_LIT:GET>' <EOL> messages . error ( request , e . message ) <EOL> return super ( XOSAdminMixin , self ) . change_view ( request , object_id , extra_context = extra_context ) <EOL> else : <EOL> raise <EOL> if request . method == '<STR_LIT:POST>' : <EOL> raise PermissionDenied <EOL> request . readonly = True <EOL> return super ( XOSAdminMixin , self ) . change_view ( request , object_id , extra_context = extra_context ) <EOL> def changelist_view ( self , request , extra_context = None ) : <EOL> extra_context = extra_context or { } <EOL> self . add_extra_context ( request , extra_context ) <EOL> return super ( XOSAdminMixin , self ) . changelist_view ( request , extra_context = extra_context ) <EOL> def add_view ( self , request , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> extra_context = extra_context or { } <EOL> self . add_extra_context ( request , extra_context ) <EOL> return super ( XOSAdminMixin , self ) . add_view ( request , form_url , extra_context = extra_context ) <EOL> def __user_is_readonly ( self , request ) : <EOL> return request . user . isReadOnlyUser ( ) <EOL> def backend_status_text ( self , obj ) : <EOL> return mark_safe ( backend_text ( obj ) ) <EOL> def backend_status_icon ( self , obj ) : <EOL> return mark_safe ( backend_icon ( obj ) ) <EOL> backend_status_icon . short_description = "<STR_LIT>" <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> _thread_locals . request = request <EOL> _thread_locals . obj = obj <EOL> return super ( XOSAdminMixin , self ) . get_form ( request , obj , ** kwargs ) <EOL> def get_inline_instances ( self , request , obj = None ) : <EOL> inlines = super ( XOSAdminMixin , self ) . get_inline_instances ( request , obj ) <EOL> if request . user . is_admin : <EOL> for inline_class in getattr ( self , "<STR_LIT>" , [ ] ) : <EOL> inlines . append ( inline_class ( self . model , self . admin_site ) ) <EOL> return inlines <EOL> class ReadOnlyAwareAdmin ( XOSAdminMixin , admin . ModelAdmin ) : <EOL> pass <EOL> class XOSBaseAdmin ( ReadOnlyAwareAdmin ) : <EOL> save_on_top = False <EOL> class SingletonAdmin ( ReadOnlyAwareAdmin ) : <EOL> def has_add_permission ( self , request ) : <EOL> if not super ( SingletonAdmin , self ) . has_add_permission ( request ) : <EOL> return False <EOL> num_objects = self . model . objects . count ( ) <EOL> if num_objects >= <NUM_LIT:1> : <EOL> return False <EOL> else : <EOL> return True <EOL> class ServiceAppAdmin ( SingletonAdmin ) : <EOL> extracontext_registered_admins = True <EOL> class XOSTabularInline ( admin . TabularInline ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( XOSTabularInline , self ) . __init__ ( * args , ** kwargs ) <EOL> self . setup_selflink ( ) <EOL> @ property <EOL> def selflink_model ( self ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> return getattr ( self . model , self . selflink_fieldname ) . field . rel . to <EOL> else : <EOL> return self . model <EOL> @ property <EOL> def selflink_reverse_path ( self ) : <EOL> return "<STR_LIT>" % ( self . selflink_model . _meta . db_table ) <EOL> def get_change_url ( self , id ) : <EOL> """<STR_LIT>""" <EOL> reverse_path = self . selflink_reverse_path <EOL> try : <EOL> url = reverse ( reverse_path , args = ( id , ) ) <EOL> except NoReverseMatch : <EOL> return None <EOL> return url <EOL> def setup_selflink ( self ) : <EOL> url = self . get_change_url ( <NUM_LIT:0> ) <EOL> if ( url == None ) : <EOL> return <EOL> if ( self . fields is None ) : <EOL> self . fields = [ ] <EOL> for f in self . model . _meta . fields : <EOL> if f . editable and f . name != "<STR_LIT:id>" : <EOL> self . fields . append ( f . name ) <EOL> self . fields = tuple ( self . fields ) + ( "<STR_LIT>" , ) <EOL> if self . readonly_fields is None : <EOL> self . readonly_fields = ( ) <EOL> self . readonly_fields = tuple ( self . readonly_fields ) + ( "<STR_LIT>" , ) <EOL> def selflink ( self , obj ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> obj = getattr ( obj , self . selflink_fieldname ) <EOL> if obj . id : <EOL> url = self . get_change_url ( obj . id ) <EOL> return "<STR_LIT>" % str ( url ) <EOL> else : <EOL> return "<STR_LIT>" <EOL> selflink . allow_tags = True <EOL> selflink . short_description = "<STR_LIT>" <EOL> def has_add_permission ( self , request ) : <EOL> return not request . user . isReadOnlyUser ( ) <EOL> def get_readonly_fields ( self , request , obj = None ) : <EOL> readonly_fields = list ( self . readonly_fields ) [ : ] <EOL> if request . user . isReadOnlyUser ( ) : <EOL> for field in self . fields : <EOL> if not field in readonly_fields : <EOL> readonly_fields . append ( field ) <EOL> return readonly_fields <EOL> def backend_status_icon ( self , obj ) : <EOL> return mark_safe ( backend_icon ( obj ) ) <EOL> backend_status_icon . short_description = "<STR_LIT>" <EOL> class PlStackGenericTabularInline ( generic . GenericTabularInline ) : <EOL> def has_add_permission ( self , request ) : <EOL> return not request . user . isReadOnlyUser ( ) <EOL> def get_readonly_fields ( self , request , obj = None ) : <EOL> readonly_fields = list ( self . readonly_fields ) [ : ] <EOL> if request . user . isReadOnlyUser ( ) : <EOL> for field in self . fields : <EOL> if not field in readonly_fields : <EOL> readonly_fields . append ( field ) <EOL> return readonly_fields <EOL> def backend_status_icon ( self , obj ) : <EOL> return mark_safe ( backend_icon ( obj ) ) <EOL> backend_status_icon . short_description = "<STR_LIT>" <EOL> class ReservationInline ( XOSTabularInline ) : <EOL> model = Reservation <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return Reservation . select_by_user ( request . user ) <EOL> class TagInline ( PlStackGenericTabularInline ) : <EOL> model = Tag <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:value>' ] <EOL> def queryset ( self , request ) : <EOL> return Tag . select_by_user ( request . user ) <EOL> class InstanceInline ( XOSTabularInline ) : <EOL> model = Instance <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> max_num = <NUM_LIT:0> <EOL> readonly_fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' ] <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return Instance . select_by_user ( request . user ) <EOL> def formfield_for_foreignkey ( self , db_field , request = None , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Deployment . select_by_acl ( request . user ) . filter ( <EOL> sitedeployments__nodes__isnull = False ) . distinct ( ) <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> field = super ( InstanceInline , self ) . formfield_for_foreignkey ( <EOL> db_field , request , ** kwargs ) <EOL> return field <EOL> class CordInstanceInline ( XOSTabularInline ) : <EOL> model = Instance <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> readonly_fields = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return Instance . select_by_user ( request . user ) <EOL> def formfield_for_foreignkey ( self , db_field , request = None , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Deployment . select_by_acl ( request . user ) . filter ( <EOL> sitedeployments__nodes__isnull = False ) . distinct ( ) <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> field = super ( CordInstanceInline , self ) . formfield_for_foreignkey ( <EOL> db_field , request , ** kwargs ) <EOL> return field <EOL> class SiteInline ( XOSTabularInline ) : <EOL> model = Site <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return Site . select_by_user ( request . user ) <EOL> class SiteHostsNodesInline ( SiteInline ) : <EOL> def queryset ( self , request ) : <EOL> return Site . select_by_user ( request . user ) . filter ( hosts_nodes = True ) <EOL> class SiteHostsUsersInline ( SiteInline ) : <EOL> def queryset ( self , request ) : <EOL> return Site . select_by_user ( request . user ) . filter ( hosts_users = True ) <EOL> class UserInline ( XOSTabularInline ) : <EOL> model = User <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return User . select_by_user ( request . user ) <EOL> class SliceInline ( XOSTabularInline ) : <EOL> model = Slice <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> return Slice . select_by_user ( request . user ) <EOL> class NodeInline ( XOSTabularInline ) : <EOL> model = Node <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class DeploymentPrivilegeInline ( XOSTabularInline ) : <EOL> model = DeploymentPrivilege <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def queryset ( self , request ) : <EOL> return DeploymentPrivilege . select_by_user ( request . user ) <EOL> class ControllerSiteInline ( XOSTabularInline ) : <EOL> model = ControllerSite <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class SitePrivilegeInline ( XOSTabularInline ) : <EOL> model = SitePrivilege <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Site . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> kwargs [ '<STR_LIT>' ] = User . select_by_user ( request . user ) <EOL> return super ( SitePrivilegeInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return SitePrivilege . select_by_user ( request . user ) <EOL> class ServicePrivilegeInline ( XOSTabularInline ) : <EOL> model = ServicePrivilege <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Service . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> kwargs [ '<STR_LIT>' ] = User . select_by_user ( request . user ) <EOL> return super ( ServicePrivilegeInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return ServicePrivilege . select_by_user ( request . user ) <EOL> class SiteDeploymentInline ( XOSTabularInline ) : <EOL> model = SiteDeployment <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Site . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Deployment . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> if len ( resolve ( request . path ) . args ) > <NUM_LIT:0> : <EOL> kwargs [ '<STR_LIT>' ] = Controller . select_by_user ( request . user ) . filter ( <EOL> deployment__id = int ( resolve ( request . path ) . args [ <NUM_LIT:0> ] ) ) <EOL> return super ( SiteDeploymentInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return SiteDeployment . select_by_user ( request . user ) <EOL> class SlicePrivilegeInline ( XOSTabularInline ) : <EOL> model = SlicePrivilege <EOL> suit_classes = '<STR_LIT>' <EOL> extra = <NUM_LIT:0> <EOL> fields = ( '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Slice . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> kwargs [ '<STR_LIT>' ] = User . objects . all ( ) <EOL> return super ( SlicePrivilegeInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return SlicePrivilege . select_by_user ( request . user ) <EOL> class SliceNetworkInline ( XOSTabularInline ) : <EOL> model = Network . slices . through <EOL> selflink_fieldname = "<STR_LIT>" <EOL> extra = <NUM_LIT:0> <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class ImageDeploymentsInline ( XOSTabularInline ) : <EOL> model = ImageDeployments <EOL> extra = <NUM_LIT:0> <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' ] <EOL> readonly_fields = [ '<STR_LIT>' ] <EOL> class ControllerImagesInline ( XOSTabularInline ) : <EOL> model = ControllerImages <EOL> extra = <NUM_LIT:0> <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class SliceRoleAdmin ( XOSBaseAdmin ) : <EOL> model = SliceRole <EOL> pass <EOL> class SiteRoleAdmin ( XOSBaseAdmin ) : <EOL> model = SiteRole <EOL> pass <EOL> class DeploymentAdminForm ( forms . ModelForm ) : <EOL> images = forms . ModelMultipleChoiceField ( <EOL> queryset = Image . objects . all ( ) , <EOL> required = False , <EOL> help_text = "<STR_LIT>" , <EOL> widget = FilteredSelectMultiple ( <EOL> verbose_name = ( '<STR_LIT>' ) , is_stacked = False <EOL> ) <EOL> ) <EOL> flavors = forms . ModelMultipleChoiceField ( <EOL> queryset = Flavor . objects . all ( ) , <EOL> required = False , <EOL> help_text = "<STR_LIT>" , <EOL> widget = FilteredSelectMultiple ( <EOL> verbose_name = ( '<STR_LIT>' ) , is_stacked = False <EOL> ) <EOL> ) <EOL> class Meta : <EOL> model = Deployment <EOL> many_to_many = [ "<STR_LIT>" , ] <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> request = kwargs . pop ( '<STR_LIT>' , None ) <EOL> super ( DeploymentAdminForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . initial = "<STR_LIT>" + request . user . site . name <EOL> if self . instance and self . instance . pk : <EOL> self . fields [ '<STR_LIT>' ] . initial = [ <EOL> x . image for x in self . instance . imagedeployments . all ( ) ] <EOL> self . fields [ '<STR_LIT>' ] . initial = self . instance . flavors . all ( ) <EOL> def manipulate_m2m_objs ( self , this_obj , selected_objs , all_relations , relation_class , local_attrname , foreign_attrname ) : <EOL> """<STR_LIT>""" <EOL> existing_dest_objs = [ ] <EOL> for relation in list ( all_relations ) : <EOL> if getattr ( relation , foreign_attrname ) not in selected_objs : <EOL> relation . delete ( ) <EOL> else : <EOL> existing_dest_objs . append ( getattr ( relation , foreign_attrname ) ) <EOL> for dest_obj in selected_objs : <EOL> if dest_obj not in existing_dest_objs : <EOL> kwargs = { foreign_attrname : dest_obj , local_attrname : this_obj } <EOL> relation = relation_class ( ** kwargs ) <EOL> relation . save ( ) <EOL> def save ( self , commit = True ) : <EOL> deployment = super ( DeploymentAdminForm , self ) . save ( commit = False ) <EOL> if commit : <EOL> deployment . save ( ) <EOL> deployment . flavors = self . cleaned_data [ '<STR_LIT>' ] <EOL> if deployment . pk : <EOL> self . manipulate_m2m_objs ( deployment , self . cleaned_data [ <EOL> '<STR_LIT>' ] , deployment . imagedeployments . all ( ) , ImageDeployments , "<STR_LIT>" , "<STR_LIT:image>" ) <EOL> for flavor in deployment . flavors . all ( ) : <EOL> if getattr ( flavor , '<STR_LIT:name>' ) not in self . cleaned_data [ '<STR_LIT>' ] : <EOL> deployment . flavors . remove ( flavor ) <EOL> for flavor in self . cleaned_data [ '<STR_LIT>' ] : <EOL> if flavor not in deployment . flavors . all ( ) : <EOL> flavor . deployments . add ( deployment ) <EOL> self . save_m2m ( ) <EOL> return deployment <EOL> class DeploymentAdminROForm ( DeploymentAdminForm ) : <EOL> def save ( self , commit = True ) : <EOL> raise PermissionDenied <EOL> class SiteAssocInline ( XOSTabularInline ) : <EOL> model = Site . deployments . through <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> class DeploymentAdmin ( XOSBaseAdmin ) : <EOL> model = Deployment <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT:name>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> inlines = [ DeploymentPrivilegeInline , TagInline , <EOL> ImageDeploymentsInline , SiteDeploymentInline ] <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT:name>' ] <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> user_readonly_fields = [ '<STR_LIT:name>' ] <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> if request . user . isReadOnlyUser ( ) or not request . user . is_admin : <EOL> kwargs [ "<STR_LIT>" ] = DeploymentAdminROForm <EOL> else : <EOL> kwargs [ "<STR_LIT>" ] = DeploymentAdminForm <EOL> adminForm = super ( DeploymentAdmin , self ) . get_form ( <EOL> request , obj , ** kwargs ) <EOL> class AdminFormMetaClass ( adminForm ) : <EOL> def __new__ ( cls , * args , ** kwargs ) : <EOL> kwargs [ '<STR_LIT>' ] = request <EOL> return adminForm ( * args , ** kwargs ) <EOL> return AdminFormMetaClass <EOL> class ControllerAdminForm ( forms . ModelForm ) : <EOL> backend_disabled = forms . BooleanField ( required = False ) <EOL> class Meta : <EOL> model = Controller <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> request = kwargs . pop ( '<STR_LIT>' , None ) <EOL> super ( ControllerAdminForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if self . instance and self . instance . pk : <EOL> self . fields [ '<STR_LIT>' ] . initial = self . instance . get_backend_register ( <EOL> '<STR_LIT>' , False ) <EOL> else : <EOL> self . fields [ '<STR_LIT>' ] . initial = False <EOL> def save ( self , commit = True ) : <EOL> self . instance . set_backend_register ( <EOL> "<STR_LIT>" , self . cleaned_data [ "<STR_LIT>" ] ) <EOL> return super ( ControllerAdminForm , self ) . save ( commit = commit ) <EOL> class ControllerAdmin ( XOSBaseAdmin ) : <EOL> model = Controller <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:version>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> inlines = [ ControllerSiteInline ] <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:version>' , '<STR_LIT>' ] <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> form = ControllerAdminForm <EOL> user_readonly_fields = [ ] <EOL> def save_model ( self , request , obj , form , change ) : <EOL> obj . save_by_user ( request . user ) <EOL> def delete_model ( self , request , obj ) : <EOL> obj . delete_by_user ( request . user ) <EOL> def queryset ( self , request ) : <EOL> return Controller . select_by_user ( request . user ) <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> class TenantAttributeAdmin ( XOSBaseAdmin ) : <EOL> model = TenantAttribute <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:value>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' ) <EOL> fieldList = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:value>' , ) <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> class TenantAttrAsTabInline ( XOSTabularInline ) : <EOL> model = TenantAttribute <EOL> fields = [ '<STR_LIT:name>' , '<STR_LIT:value>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> class TenantRootRoleAdmin ( XOSBaseAdmin ) : <EOL> model = TenantRootRole <EOL> fields = ( '<STR_LIT>' , ) <EOL> class TenantRootTenantInline ( XOSTabularInline ) : <EOL> model = Tenant <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fk_name = '<STR_LIT>' <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> class TenantRootPrivilegeInline ( XOSTabularInline ) : <EOL> model = TenantRootPrivilege <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def queryset ( self , request ) : <EOL> return TenantRootPrivilege . select_by_user ( request . user ) <EOL> class TenantRootAdmin ( XOSBaseAdmin ) : <EOL> model = TenantRoot <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' ) <EOL> fieldList = ( '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , ) <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> inlines = ( TenantRootTenantInline , TenantRootPrivilegeInline ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) <EOL> class TenantRoleAdmin ( XOSBaseAdmin ) : <EOL> """<STR_LIT>""" <EOL> model = TenantRole <EOL> fields = ( '<STR_LIT>' , ) <EOL> class TenantPrivilegeInline ( XOSTabularInline ) : <EOL> """<STR_LIT>""" <EOL> model = TenantPrivilege <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> def queryset ( self , request ) : <EOL> return TenantPrivilege . select_by_user ( request . user ) <EOL> class ProviderTenantInline ( XOSTabularInline ) : <EOL> model = CoarseTenant <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fk_name = '<STR_LIT>' <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> qs = super ( ProviderTenantInline , self ) . queryset ( request ) <EOL> return qs . filter ( kind = "<STR_LIT>" ) <EOL> class SubscriberTenantInline ( XOSTabularInline ) : <EOL> model = CoarseTenant <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fk_name = '<STR_LIT>' <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> def queryset ( self , request ) : <EOL> qs = super ( SubscriberTenantInline , self ) . queryset ( request ) <EOL> return qs . filter ( kind = "<STR_LIT>" ) <EOL> class ServiceAttrAsTabInline ( XOSTabularInline ) : <EOL> model = ServiceAttribute <EOL> fields = [ '<STR_LIT:name>' , '<STR_LIT:value>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> class ServiceAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> fieldList = [ "<STR_LIT>" , "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT:description>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> inlines = [ ServiceAttrAsTabInline , SliceInline , ProviderTenantInline , <EOL> SubscriberTenantInline , ServicePrivilegeInline ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> user_readonly_fields = fieldList <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) <EOL> class SiteNodeInline ( XOSTabularInline ) : <EOL> model = Node <EOL> fields = [ '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = SiteDeployment . objects . filter ( <EOL> site__id = int ( request . path . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:2> ] ) ) <EOL> return super ( SiteNodeInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> class SiteAdmin ( XOSBaseAdmin ) : <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:location>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ <EOL> '<STR_LIT>' ] } ) , <EOL> ] <EOL> readonly_fields = [ '<STR_LIT>' ] <EOL> user_readonly_fields = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:name>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> filter_horizontal = ( '<STR_LIT>' , ) <EOL> inlines = [ SliceInline , UserInline , TagInline , <EOL> SitePrivilegeInline , SiteNodeInline ] <EOL> admin_inlines = [ ControllerSiteInline ] <EOL> search_fields = [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> def queryset ( self , request ) : <EOL> return Site . select_by_user ( request . user ) <EOL> def get_formsets ( self , request , obj = None ) : <EOL> for inline in self . get_inline_instances ( request , obj ) : <EOL> if obj is None : <EOL> continue <EOL> if isinstance ( inline , InstanceInline ) : <EOL> inline . model . caller = request . user <EOL> yield inline . get_formset ( request , obj ) <EOL> def accountLink ( self , obj ) : <EOL> link_obj = obj . accounts . all ( ) <EOL> if link_obj : <EOL> reverse_path = "<STR_LIT>" <EOL> url = reverse ( reverse_path , args = ( link_obj [ <NUM_LIT:0> ] . id , ) ) <EOL> return "<STR_LIT>" % ( url , "<STR_LIT>" ) <EOL> else : <EOL> return "<STR_LIT>" <EOL> accountLink . allow_tags = True <EOL> accountLink . short_description = "<STR_LIT>" <EOL> def save_model ( self , request , obj , form , change ) : <EOL> obj . save_by_user ( request . user ) <EOL> def delete_model ( self , request , obj ) : <EOL> obj . delete_by_user ( request . user ) <EOL> class SitePrivilegeAdmin ( XOSBaseAdmin ) : <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = list_display <EOL> user_readonly_fields = fieldList <EOL> user_readonly_inlines = [ ] <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> if not request . user . is_admin : <EOL> sites = set ( ) <EOL> for site_privilege in SitePrivilege . objects . filer ( user = request . user ) : <EOL> if site_privilege . role . role_type in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> sites . add ( site_privilege . site ) <EOL> kwargs [ '<STR_LIT>' ] = Site . objects . filter ( site__in = list ( sites ) ) <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> if not request . user . is_admin : <EOL> roles = Role . objects . filter ( role_type__in = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> site_privileges = SitePrivilege . objects . filter ( <EOL> user = request . user ) . filter ( role__in = roles ) <EOL> sites = [ site_privilege . site for site_privilege in site_privileges ] <EOL> site_privileges = SitePrivilege . objects . filter ( site__in = sites ) <EOL> emails = [ <EOL> site_privilege . user . email for site_privilege in site_privileges ] <EOL> users = User . objects . filter ( email__in = emails ) <EOL> kwargs [ '<STR_LIT>' ] = users <EOL> return super ( SitePrivilegeAdmin , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> qs = super ( SitePrivilegeAdmin , self ) . queryset ( request ) <EOL> return qs <EOL> class SliceForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Slice <EOL> widgets = { <EOL> '<STR_LIT>' : LinkedSelect <EOL> } <EOL> def clean ( self ) : <EOL> cleaned_data = super ( SliceForm , self ) . clean ( ) <EOL> name = cleaned_data . get ( '<STR_LIT:name>' ) <EOL> site = cleaned_data . get ( '<STR_LIT>' ) <EOL> slice_id = self . instance . id <EOL> if not site and slice_id : <EOL> site = Slice . objects . get ( id = slice_id ) . site <EOL> if ( not isinstance ( site , Site ) ) : <EOL> site = Slice . objects . get ( id = site . id ) <EOL> if not name . startswith ( site . login_base ) : <EOL> raise forms . ValidationError ( <EOL> '<STR_LIT>' % site . login_base ) <EOL> return cleaned_data <EOL> class ControllerSliceInline ( XOSTabularInline ) : <EOL> model = ControllerSlice <EOL> extra = <NUM_LIT:0> <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class SliceAdmin ( XOSBaseAdmin ) : <EOL> form = SliceForm <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , "<STR_LIT>" , "<STR_LIT>" ] <EOL> fieldsets = [ ( '<STR_LIT>' , { '<STR_LIT>' : fieldList , '<STR_LIT>' : [ <EOL> '<STR_LIT>' ] } ) , ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> normal_inlines = [ SlicePrivilegeInline , InstanceInline , <EOL> TagInline , ReservationInline , SliceNetworkInline ] <EOL> inlines = normal_inlines <EOL> admin_inlines = [ ControllerSliceInline ] <EOL> suit_form_includes = ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , ) <EOL> user_readonly_fields = fieldList <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> def add_view ( self , request , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> self . inlines = self . normal_inlines <EOL> self . readonly_fields = ( '<STR_LIT>' , ) <EOL> return super ( SliceAdmin , self ) . add_view ( request , form_url , extra_context = extra_context ) <EOL> def change_view ( self , request , object_id , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> if object_id : <EOL> self . readonly_fields = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return super ( SliceAdmin , self ) . change_view ( request , object_id , form_url ) <EOL> def render_change_form ( self , request , context , add = False , change = False , form_url = '<STR_LIT>' , obj = None ) : <EOL> deployment_nodes = [ ] <EOL> for node in Node . objects . all ( ) : <EOL> deployment_nodes . append ( <EOL> ( node . site_deployment . deployment . id , node . id , node . name ) ) <EOL> deployment_flavors = [ ] <EOL> for flavor in Flavor . objects . all ( ) : <EOL> for deployment in flavor . deployments . all ( ) : <EOL> deployment_flavors . append ( <EOL> ( deployment . id , flavor . id , flavor . name ) ) <EOL> deployment_images = [ ] <EOL> for image in Image . objects . all ( ) : <EOL> for deployment_image in image . imagedeployments . all ( ) : <EOL> deployment_images . append ( <EOL> ( deployment_image . deployment . id , image . id , image . name ) ) <EOL> site_login_bases = [ ] <EOL> for site in Site . objects . all ( ) : <EOL> site_login_bases . append ( ( site . id , site . login_base ) ) <EOL> context [ "<STR_LIT>" ] = deployment_nodes <EOL> context [ "<STR_LIT>" ] = deployment_flavors <EOL> context [ "<STR_LIT>" ] = deployment_images <EOL> context [ "<STR_LIT>" ] = site_login_bases <EOL> return super ( SliceAdmin , self ) . render_change_form ( request , context , add , change , form_url , obj ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Site . select_by_user ( <EOL> request . user ) . filter ( hosts_users = True ) <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> return super ( SliceAdmin , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return Slice . select_by_user ( request . user ) <EOL> def get_formsets ( self , request , obj = None ) : <EOL> for inline in self . get_inline_instances ( request , obj ) : <EOL> if obj is None : <EOL> continue <EOL> if isinstance ( inline , InstanceInline ) : <EOL> inline . model . caller = request . user <EOL> yield inline . get_formset ( request , obj ) <EOL> def add_extra_context ( self , request , extra_context ) : <EOL> super ( SliceAdmin , self ) . add_extra_context ( request , extra_context ) <EOL> if len ( request . resolver_match . args ) > <NUM_LIT:0> : <EOL> extra_context [ "<STR_LIT>" ] = request . resolver_match . args [ <NUM_LIT:0> ] <EOL> def UNUSED_get_inline_instances ( self , request , obj = None ) : <EOL> if ( obj is not None ) and ( obj . name == "<STR_LIT>" ) : <EOL> cord_vcpe_inlines = [ SlicePrivilegeInline , CordInstanceInline , <EOL> TagInline , ReservationInline , SliceNetworkInline ] <EOL> inlines = [ ] <EOL> for inline_class in cord_vcpe_inlines : <EOL> inlines . append ( inline_class ( self . model , self . admin_site ) ) <EOL> else : <EOL> inlines = super ( SliceAdmin , self ) . get_inline_instances ( <EOL> request , obj ) <EOL> return inlines <EOL> class SlicePrivilegeAdmin ( XOSBaseAdmin ) : <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = list_display <EOL> user_readonly_fields = [ '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> user_readonly_inlines = [ ] <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Slice . select_by_user ( request . user ) <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> kwargs [ '<STR_LIT>' ] = User . select_by_user ( request . user ) <EOL> return super ( SlicePrivilegeAdmin , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return SlicePrivilege . select_by_user ( request . user ) <EOL> def save_model ( self , request , obj , form , change ) : <EOL> auth = request . session . get ( '<STR_LIT>' , { } ) <EOL> auth [ '<STR_LIT>' ] = obj . slice . slicename <EOL> obj . os_manager = OpenStackManager ( auth = auth , caller = request . user ) <EOL> obj . save ( ) <EOL> def delete_model ( self , request , obj ) : <EOL> auth = request . session . get ( '<STR_LIT>' , { } ) <EOL> auth [ '<STR_LIT>' ] = obj . slice . slicename <EOL> obj . os_manager = OpenStackManager ( auth = auth , caller = request . user ) <EOL> obj . delete ( ) <EOL> class ImageAdmin ( XOSBaseAdmin ) : <EOL> fieldsets = [ ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:path>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> inlines = [ InstanceInline , ControllerImagesInline ] <EOL> user_readonly_fields = [ '<STR_LIT:name>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:path>' ] <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> class NodeForm ( forms . ModelForm ) : <EOL> nodelabels = forms . ModelMultipleChoiceField ( <EOL> queryset = NodeLabel . objects . all ( ) , <EOL> required = False , <EOL> help_text = "<STR_LIT>" , <EOL> widget = FilteredSelectMultiple ( <EOL> verbose_name = ( '<STR_LIT>' ) , is_stacked = False <EOL> ) <EOL> ) <EOL> class Meta : <EOL> model = Node <EOL> widgets = { <EOL> '<STR_LIT>' : LinkedSelect , <EOL> '<STR_LIT>' : LinkedSelect <EOL> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> request = kwargs . pop ( '<STR_LIT>' , None ) <EOL> super ( NodeForm , self ) . __init__ ( * args , ** kwargs ) <EOL> if self . instance and self . instance . pk : <EOL> self . fields [ '<STR_LIT>' ] . initial = self . instance . nodelabels . all ( ) <EOL> def save ( self , commit = True ) : <EOL> node = super ( NodeForm , self ) . save ( commit = False ) <EOL> node . nodelabels = self . cleaned_data [ '<STR_LIT>' ] <EOL> if commit : <EOL> node . save ( ) <EOL> return node <EOL> class NodeLabelAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , ) <EOL> list_display_links = ( '<STR_LIT:name>' , ) <EOL> fields = ( '<STR_LIT:name>' , ) <EOL> class NodeAdmin ( XOSBaseAdmin ) : <EOL> form = NodeForm <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> inlines = [ TagInline , InstanceInline ] <EOL> fieldsets = [ ( '<STR_LIT>' , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : [ '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> user_readonly_fields = [ '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> user_readonly_inlines = [ TagInline , InstanceInline ] <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Site . select_by_user ( <EOL> request . user ) . filter ( hosts_nodes = True ) <EOL> field = super ( NodeAdmin , self ) . formfield_for_foreignkey ( <EOL> db_field , request , ** kwargs ) <EOL> return field <EOL> class InstanceForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Instance <EOL> ip = forms . CharField ( widget = PlainTextWidget ) <EOL> instance_name = forms . CharField ( widget = PlainTextWidget ) <EOL> widgets = { <EOL> '<STR_LIT>' : PlainTextWidget ( ) , <EOL> '<STR_LIT>' : PlainTextWidget ( ) , <EOL> '<STR_LIT>' : PlainTextWidget ( ) , <EOL> '<STR_LIT>' : LinkedSelect , <EOL> '<STR_LIT>' : LinkedSelect , <EOL> '<STR_LIT>' : LinkedSelect , <EOL> '<STR_LIT:image>' : LinkedSelect <EOL> } <EOL> class TagAdmin ( XOSBaseAdmin ) : <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:name>' , '<STR_LIT:value>' , '<STR_LIT>' , '<STR_LIT>' , ] <EOL> list_display_links = list_display <EOL> user_readonly_fields = [ '<STR_LIT>' , '<STR_LIT:name>' , <EOL> '<STR_LIT:value>' , '<STR_LIT>' , '<STR_LIT>' , ] <EOL> user_readonly_inlines = [ ] <EOL> class InstancePortInline ( XOSTabularInline ) : <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> model = Port <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> class InstanceAdmin ( XOSBaseAdmin ) : <EOL> form = InstanceForm <EOL> fieldsets = [ <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ] , '<STR_LIT>' : [ '<STR_LIT>' ] , } ) , <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : [ '<STR_LIT>' ] , '<STR_LIT>' : [ <EOL> '<STR_LIT>' ] , } ) , <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_display_links = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , ) <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> inlines = [ TagInline , InstancePortInline ] <EOL> user_readonly_fields = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' ] <EOL> def ssh_command ( self , obj ) : <EOL> ssh_command = obj . get_ssh_command ( ) <EOL> if ssh_command : <EOL> return ssh_command <EOL> else : <EOL> return "<STR_LIT>" <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Slice . select_by_user ( request . user ) <EOL> return super ( InstanceAdmin , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return Instance . select_by_user ( request . user ) <EOL> def add_view ( self , request , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> self . readonly_fields = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> return super ( InstanceAdmin , self ) . add_view ( request , form_url , extra_context ) <EOL> def change_view ( self , request , object_id , extra_context = None ) : <EOL> self . readonly_fields = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:image>' , '<STR_LIT>' ) <EOL> self . readonly_save = self . readonly_fields <EOL> return super ( InstanceAdmin , self ) . change_view ( request , object_id , extra_context ) <EOL> def render_change_form ( self , request , context , add = False , change = False , form_url = '<STR_LIT>' , obj = None ) : <EOL> deployment_nodes = [ ] <EOL> for node in Node . objects . order_by ( "<STR_LIT:name>" ) : <EOL> deployment_nodes . append ( <EOL> ( node . site_deployment . deployment . id , node . id , node . name ) ) <EOL> deployment_flavors = [ ] <EOL> for flavor in Flavor . objects . all ( ) : <EOL> for deployment in flavor . deployments . all ( ) : <EOL> deployment_flavors . append ( <EOL> ( deployment . id , flavor . id , flavor . name ) ) <EOL> deployment_images = [ ] <EOL> for image in Image . objects . all ( ) : <EOL> for deployment_image in image . imagedeployments . all ( ) : <EOL> deployment_images . append ( <EOL> ( deployment_image . deployment . id , image . id , image . name ) ) <EOL> site_login_bases = [ ] <EOL> for site in Site . objects . all ( ) : <EOL> site_login_bases . append ( ( site . id , site . login_base ) ) <EOL> context [ "<STR_LIT>" ] = deployment_nodes <EOL> context [ "<STR_LIT>" ] = deployment_flavors <EOL> context [ "<STR_LIT>" ] = deployment_images <EOL> context [ "<STR_LIT>" ] = site_login_bases <EOL> return super ( InstanceAdmin , self ) . render_change_form ( request , context , add , change , form_url , obj ) <EOL> def formfield_for_foreignkey ( self , db_field , request = None , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Deployment . select_by_acl ( request . user ) . filter ( <EOL> sitedeployments__nodes__isnull = False ) . distinct ( ) <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = forms . Select ( <EOL> attrs = { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> field = super ( InstanceAdmin , self ) . formfield_for_foreignkey ( <EOL> db_field , request , ** kwargs ) <EOL> return field <EOL> class UserCreationForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> password1 = forms . CharField ( label = '<STR_LIT>' , widget = forms . PasswordInput ) <EOL> password2 = forms . CharField ( <EOL> label = '<STR_LIT>' , widget = forms . PasswordInput ) <EOL> class Meta : <EOL> model = User <EOL> fields = ( '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def clean_password2 ( self ) : <EOL> password1 = self . cleaned_data . get ( "<STR_LIT>" ) <EOL> password2 = self . cleaned_data . get ( "<STR_LIT>" ) <EOL> if password1 and password2 and password1 != password2 : <EOL> raise forms . ValidationError ( "<STR_LIT>" ) <EOL> return password2 <EOL> def save ( self , commit = True ) : <EOL> user = super ( UserCreationForm , self ) . save ( commit = False ) <EOL> user . password = self . cleaned_data [ "<STR_LIT>" ] <EOL> if commit : <EOL> user . save ( ) <EOL> return user <EOL> class UserChangeForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> password = ReadOnlyPasswordHashField ( label = '<STR_LIT>' , <EOL> help_text = '<STR_LIT>' ) <EOL> PROFILE_CHOICES = ( ( None , '<STR_LIT>' ) , ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> profile = forms . ChoiceField ( <EOL> choices = PROFILE_CHOICES , required = False , label = "<STR_LIT>" ) <EOL> class Meta : <EOL> model = User <EOL> widgets = { '<STR_LIT>' : UploadTextareaWidget , } <EOL> def clean_password ( self ) : <EOL> return self . initial [ "<STR_LIT:password>" ] <EOL> def save ( self , * args , ** kwargs ) : <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> self . instance . apply_profile ( self . cleaned_data [ '<STR_LIT>' ] ) <EOL> return super ( UserChangeForm , self ) . save ( * args , ** kwargs ) <EOL> class UserDashboardViewInline ( XOSTabularInline ) : <EOL> model = UserDashboardView <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class ControllerUserInline ( XOSTabularInline ) : <EOL> model = ControllerUser <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' ] <EOL> class UserAdmin ( XOSAdminMixin , UserAdmin ) : <EOL> class Meta : <EOL> app_label = "<STR_LIT>" <EOL> form = UserChangeForm <EOL> add_form = UserCreationForm <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:email>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = ( "<STR_LIT:email>" , ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> inlines = [ SlicePrivilegeInline , SitePrivilegeInline ] <EOL> admin_inlines = [ ControllerUserInline ] <EOL> fieldListLoginDetails = [ '<STR_LIT>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT:password>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldListContactInfo = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = ( <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT:password>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ) <EOL> add_fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) } , <EOL> ) , <EOL> ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> search_fields = ( '<STR_LIT:email>' , ) <EOL> ordering = ( '<STR_LIT:email>' , ) <EOL> filter_horizontal = ( ) <EOL> user_readonly_fields = fieldListLoginDetails + fieldListContactInfo <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> if getattr ( _thread_locals , "<STR_LIT>" , None ) is None : <EOL> return [ ] <EOL> else : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = Site . select_by_user ( <EOL> request . user ) . filter ( hosts_users = True ) <EOL> return super ( UserAdmin , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> def queryset ( self , request ) : <EOL> return User . select_by_user ( request . user ) <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> login_details_fields = list ( self . fieldListLoginDetails ) <EOL> if not request . user . is_admin : <EOL> if '<STR_LIT>' in login_details_fields : <EOL> login_details_fields . remove ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in login_details_fields : <EOL> login_details_fields . remove ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in login_details_fields : <EOL> login_details_fields . remove ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in login_details_fields : <EOL> login_details_fields . remove ( '<STR_LIT>' ) <EOL> self . fieldsets = ( <EOL> ( '<STR_LIT>' , { '<STR_LIT>' : login_details_fields , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : self . fieldListContactInfo , '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ) <EOL> return super ( UserAdmin , self ) . get_form ( request , obj , ** kwargs ) <EOL> class ControllerDashboardViewInline ( XOSTabularInline ) : <EOL> model = ControllerDashboardView <EOL> extra = <NUM_LIT:0> <EOL> fields = [ "<STR_LIT>" , "<STR_LIT:url>" ] <EOL> suit_classes = '<STR_LIT>' <EOL> class DashboardViewAdmin ( XOSBaseAdmin ) : <EOL> fieldsets = [ ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:url>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> ] <EOL> list_display = [ "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT:url>" ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> inlines = [ ControllerDashboardViewInline ] <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> class ServiceResourceInline ( XOSTabularInline ) : <EOL> model = ServiceResource <EOL> extra = <NUM_LIT:0> <EOL> class ServiceClassAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:name>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> inlines = [ ServiceResourceInline ] <EOL> user_readonly_fields = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> user_readonly_inlines = [ ] <EOL> class ReservedResourceInline ( XOSTabularInline ) : <EOL> model = ReservedResource <EOL> extra = <NUM_LIT:0> <EOL> suit_classes = '<STR_LIT>' <EOL> def formfield_for_foreignkey ( self , db_field , request = None , ** kwargs ) : <EOL> field = super ( ReservedResourceInline , self ) . formfield_for_foreignkey ( <EOL> db_field , request , ** kwargs ) <EOL> if db_field . name == '<STR_LIT>' : <EOL> if request . _slice is not None : <EOL> field . queryset = field . queryset . filter ( <EOL> serviceClass = request . _slice . serviceClass , calendarReservable = True ) <EOL> if len ( field . queryset ) > <NUM_LIT:0> : <EOL> field . initial = field . queryset . all ( ) [ <NUM_LIT:0> ] <EOL> else : <EOL> field . queryset = field . queryset . none ( ) <EOL> elif db_field . name == '<STR_LIT>' : <EOL> if request . _slice is not None : <EOL> field . queryset = field . queryset . filter ( slice = request . _slice ) <EOL> else : <EOL> field . queryset = field . queryset . none ( ) <EOL> return field <EOL> def queryset ( self , request ) : <EOL> return ReservedResource . select_by_user ( request . user ) <EOL> class ReservationChangeForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Reservation <EOL> widgets = { <EOL> '<STR_LIT>' : LinkedSelect <EOL> } <EOL> class ReservationAddForm ( forms . ModelForm ) : <EOL> slice = forms . ModelChoiceField ( queryset = Slice . objects . all ( ) , widget = forms . Select ( <EOL> attrs = { "<STR_LIT>" : "<STR_LIT>" } ) ) <EOL> refresh = forms . CharField ( widget = forms . HiddenInput ( ) ) <EOL> class Media : <EOL> css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } <EOL> def clean_slice ( self ) : <EOL> slice = self . cleaned_data . get ( "<STR_LIT>" ) <EOL> x = ServiceResource . objects . filter ( <EOL> serviceClass = slice . serviceClass , calendarReservable = True ) <EOL> if len ( x ) == <NUM_LIT:0> : <EOL> raise forms . ValidationError ( <EOL> "<STR_LIT>" ) <EOL> return slice <EOL> class Meta : <EOL> model = Reservation <EOL> widgets = { <EOL> '<STR_LIT>' : LinkedSelect <EOL> } <EOL> class ReservationAddRefreshForm ( ReservationAddForm ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> dont_validate_fields = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def full_clean ( self ) : <EOL> result = super ( ReservationAddForm , self ) . full_clean ( ) <EOL> for fieldname in self . dont_validate_fields : <EOL> if fieldname in self . _errors : <EOL> del self . _errors [ fieldname ] <EOL> return result <EOL> """<STR_LIT>""" <EOL> def is_valid ( self ) : <EOL> return False <EOL> class ReservationAdmin ( XOSBaseAdmin ) : <EOL> fieldList = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> fieldsets = [ ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : fieldList , '<STR_LIT>' : [ '<STR_LIT>' ] } ) ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> form = ReservationAddForm <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> inlines = [ ReservedResourceInline ] <EOL> user_readonly_fields = fieldList <EOL> def add_view ( self , request , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> timezone . activate ( request . user . timezone ) <EOL> request . _refresh = False <EOL> request . _slice = None <EOL> if request . method == '<STR_LIT:POST>' : <EOL> if request . POST . get ( "<STR_LIT>" , "<STR_LIT:1>" ) == "<STR_LIT:1>" : <EOL> request . _refresh = True <EOL> request . POST [ "<STR_LIT>" ] = "<STR_LIT:0>" <EOL> request . _slice = request . POST . get ( "<STR_LIT>" , None ) <EOL> if ( request . _slice is not None ) : <EOL> request . _slice = Slice . objects . get ( id = request . _slice ) <EOL> result = super ( ReservationAdmin , self ) . add_view ( <EOL> request , form_url , extra_context ) <EOL> return result <EOL> def changelist_view ( self , request , extra_context = None ) : <EOL> timezone . activate ( request . user . timezone ) <EOL> return super ( ReservationAdmin , self ) . changelist_view ( request , extra_context ) <EOL> def get_form ( self , request , obj = None , ** kwargs ) : <EOL> request . _obj_ = obj <EOL> if obj is not None : <EOL> request . _slice = obj . slice <EOL> self . form = ReservationChangeForm <EOL> else : <EOL> if getattr ( request , "<STR_LIT>" , False ) : <EOL> self . form = ReservationAddRefreshForm <EOL> else : <EOL> self . form = ReservationAddForm <EOL> return super ( ReservationAdmin , self ) . get_form ( request , obj , ** kwargs ) <EOL> def get_readonly_fields ( self , request , obj = None ) : <EOL> if ( obj is not None ) : <EOL> return [ '<STR_LIT>' ] <EOL> else : <EOL> return [ ] <EOL> def queryset ( self , request ) : <EOL> return Reservation . select_by_user ( request . user ) <EOL> class NetworkParameterTypeAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> user_readonly_fields = [ '<STR_LIT:name>' ] <EOL> user_readonly_inlines = [ ] <EOL> class RouterAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> user_readonly_fields = [ '<STR_LIT:name>' ] <EOL> user_readonly_inlines = [ ] <EOL> class RouterInline ( XOSTabularInline ) : <EOL> model = Router . networks . through <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> class NetworkParameterInline ( PlStackGenericTabularInline ) : <EOL> model = NetworkParameter <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:value>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class NetworkPortInline ( XOSTabularInline ) : <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> model = Port <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> class NetworkSlicesInline ( XOSTabularInline ) : <EOL> model = NetworkSlice <EOL> selflink_fieldname = "<STR_LIT>" <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class ControllerNetworkInline ( XOSTabularInline ) : <EOL> model = ControllerNetwork <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> suit_classes = '<STR_LIT>' <EOL> fields = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class NetworkForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Network <EOL> widgets = { <EOL> '<STR_LIT>' : UploadTextareaWidget , <EOL> '<STR_LIT>' : UploadTextareaWidget , <EOL> } <EOL> class NetworkAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> readonly_fields = ( "<STR_LIT>" , ) <EOL> inlines = [ NetworkParameterInline , NetworkPortInline , <EOL> NetworkSlicesInline , RouterInline ] <EOL> admin_inlines = [ ControllerNetworkInline ] <EOL> form = NetworkForm <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> user_readonly_fields = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> class NetworkTemplateAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:name>' , ) <EOL> user_readonly_fields = [ "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> user_readonly_inlines = [ ] <EOL> inlines = [ NetworkParameterInline , ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , ] <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> class PortAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:id>" , "<STR_LIT>" ) <EOL> list_display_links = ( '<STR_LIT>' , '<STR_LIT:id>' ) <EOL> readonly_fields = ( "<STR_LIT>" , ) <EOL> inlines = [ NetworkParameterInline ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ] <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> suit_form_tabs = ( ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> class FlavorAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT:name>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:default>" ) <EOL> list_display_links = ( "<STR_LIT>" , "<STR_LIT:name>" ) <EOL> user_readonly_fields = ( "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> fields = ( "<STR_LIT:name>" , "<STR_LIT:description>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:default>" ) <EOL> def cache_credentials ( sender , user , request , ** kwds ) : <EOL> auth = { '<STR_LIT:username>' : request . POST [ '<STR_LIT:username>' ] , <EOL> '<STR_LIT:password>' : request . POST [ '<STR_LIT:password>' ] } <EOL> request . session [ '<STR_LIT>' ] = auth <EOL> user_logged_in . connect ( cache_credentials ) <EOL> def dollar_field ( fieldName , short_description ) : <EOL> def newFunc ( self , obj ) : <EOL> try : <EOL> x = "<STR_LIT>" % float ( getattr ( obj , fieldName , <NUM_LIT:0.0> ) ) <EOL> except : <EOL> x = getattr ( obj , fieldName , <NUM_LIT:0.0> ) <EOL> return x <EOL> newFunc . short_description = short_description <EOL> return newFunc <EOL> def right_dollar_field ( fieldName , short_description ) : <EOL> def newFunc ( self , obj ) : <EOL> try : <EOL> x = '<STR_LIT>' % float ( <EOL> getattr ( obj , fieldName , <NUM_LIT:0.0> ) ) <EOL> except : <EOL> x = getattr ( obj , fieldName , <NUM_LIT:0.0> ) <EOL> return x <EOL> newFunc . short_description = short_description <EOL> newFunc . allow_tags = True <EOL> return newFunc <EOL> class InvoiceChargeInline ( XOSTabularInline ) : <EOL> model = Charge <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> exclude = [ '<STR_LIT>' ] <EOL> fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT:state>" , "<STR_LIT:object>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> readonly_fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT:state>" , <EOL> "<STR_LIT:object>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> can_delete = False <EOL> max_num = <NUM_LIT:0> <EOL> dollar_amount = right_dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class InvoiceAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( "<STR_LIT:date>" , "<STR_LIT>" ) <EOL> inlines = [ InvoiceChargeInline ] <EOL> fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> readonly_fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> dollar_amount = dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class InvoiceInline ( XOSTabularInline ) : <EOL> model = Invoice <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> fields = [ "<STR_LIT:date>" , "<STR_LIT>" ] <EOL> readonly_fields = [ "<STR_LIT:date>" , "<STR_LIT>" ] <EOL> suit_classes = '<STR_LIT>' <EOL> can_delete = False <EOL> max_num = <NUM_LIT:0> <EOL> dollar_amount = right_dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class PendingChargeInline ( XOSTabularInline ) : <EOL> model = Charge <EOL> extra = <NUM_LIT:0> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> exclude = [ "<STR_LIT>" ] <EOL> fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT:state>" , "<STR_LIT:object>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> readonly_fields = [ "<STR_LIT:date>" , "<STR_LIT>" , "<STR_LIT:state>" , <EOL> "<STR_LIT:object>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> suit_classes = '<STR_LIT>' <EOL> can_delete = False <EOL> max_num = <NUM_LIT:0> <EOL> def queryset ( self , request ) : <EOL> qs = super ( PendingChargeInline , self ) . queryset ( request ) <EOL> qs = qs . filter ( state = "<STR_LIT>" ) <EOL> return qs <EOL> dollar_amount = right_dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class PaymentInline ( XOSTabularInline ) : <EOL> model = Payment <EOL> extra = <NUM_LIT:1> <EOL> verbose_name_plural = "<STR_LIT>" <EOL> verbose_name = "<STR_LIT>" <EOL> fields = [ "<STR_LIT:date>" , "<STR_LIT>" ] <EOL> readonly_fields = [ "<STR_LIT:date>" , "<STR_LIT>" ] <EOL> suit_classes = '<STR_LIT>' <EOL> can_delete = False <EOL> max_num = <NUM_LIT:0> <EOL> dollar_amount = right_dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class AccountAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> inlines = [ InvoiceInline , PaymentInline , PendingChargeInline ] <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] } ) , ] <EOL> readonly_fields = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> suit_form_tabs = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> dollar_balance_due = dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> dollar_total_invoices = dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> dollar_total_payments = dollar_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> class ProgramForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Program <EOL> widgets = { <EOL> '<STR_LIT>' : UploadTextareaWidget ( attrs = { '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:class>' : "<STR_LIT>" } ) , <EOL> '<STR_LIT:description>' : forms . Textarea ( attrs = { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:class>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : forms . Textarea ( attrs = { '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:class>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : forms . Textarea ( attrs = { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> } <EOL> class ProgramAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT:name>" , "<STR_LIT:status>" ) <EOL> list_display_links = ( '<STR_LIT:name>' , "<STR_LIT:status>" ) <EOL> form = ProgramForm <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT:status>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ] <EOL> readonly_fields = ( "<STR_LIT:status>" , ) <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> request = getattr ( _thread_locals , "<STR_LIT>" , None ) <EOL> if request and request . user . is_admin : <EOL> tabs . append ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return tabs <EOL> class AddressPoolForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Program <EOL> widgets = { <EOL> '<STR_LIT>' : UploadTextareaWidget ( attrs = { '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:class>' : "<STR_LIT>" } ) , <EOL> } <EOL> class AddressPoolAdmin ( XOSBaseAdmin ) : <EOL> list_display = ( "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> list_display_links = ( '<STR_LIT:name>' , ) <EOL> form = AddressPoolForm <EOL> fieldsets = [ <EOL> ( None , { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } ) , <EOL> ] <EOL> readonly_fields = ( "<STR_LIT:status>" , ) <EOL> @ property <EOL> def suit_form_tabs ( self ) : <EOL> tabs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> return tabs <EOL> admin . site . register ( User , UserAdmin ) <EOL> showAll = False <EOL> admin . site . register ( Deployment , DeploymentAdmin ) <EOL> admin . site . register ( Controller , ControllerAdmin ) <EOL> admin . site . register ( Site , SiteAdmin ) <EOL> admin . site . register ( Slice , SliceAdmin ) <EOL> admin . site . register ( Service , ServiceAdmin ) <EOL> admin . site . register ( Network , NetworkAdmin ) <EOL> admin . site . register ( Port , PortAdmin ) <EOL> admin . site . register ( Router , RouterAdmin ) <EOL> admin . site . register ( NetworkTemplate , NetworkTemplateAdmin ) <EOL> admin . site . register ( Program , ProgramAdmin ) <EOL> if True : <EOL> admin . site . register ( NetworkParameterType , NetworkParameterTypeAdmin ) <EOL> admin . site . register ( ServiceClass , ServiceClassAdmin ) <EOL> admin . site . register ( Tag , TagAdmin ) <EOL> admin . site . register ( ControllerRole ) <EOL> admin . site . register ( SiteRole ) <EOL> admin . site . register ( SliceRole ) <EOL> admin . site . register ( Node , NodeAdmin ) <EOL> admin . site . register ( NodeLabel , NodeLabelAdmin ) <EOL> admin . site . register ( Instance , InstanceAdmin ) <EOL> admin . site . register ( Image , ImageAdmin ) <EOL> admin . site . register ( DashboardView , DashboardViewAdmin ) <EOL> admin . site . register ( Flavor , FlavorAdmin ) <EOL> admin . site . register ( TenantRoot , TenantRootAdmin ) <EOL> admin . site . register ( TenantRootRole , TenantRootRoleAdmin ) <EOL> admin . site . register ( TenantRole , TenantRoleAdmin ) <EOL> admin . site . register ( TenantAttribute , TenantAttributeAdmin ) <EOL> admin . site . register ( AddressPool , AddressPoolAdmin ) </s>
