#NEWLINE# @ classmethod #NEWLINE# def class_init( self ) : #NEWLINE# #INDENT# if ( self . model is not None ) : #NEWLINE# #INDENT# self . model = resolve_model ( self . model , self . app_label ) #NEWLINE# #UNINDENT# if isinstance ( self . model , UnresolvedModel ) : #NEWLINE# #INDENT# self . model = None #NEWLINE# #UNINDENT# if ( self . model is not None ) : #NEWLINE# #INDENT# if isinstance ( self . hidden_columns , basestring ) : #NEWLINE# #INDENT# self . hidden_columns = frozenset ( fields . fields_list ( self . model , self . hidden_columns ) ) #NEWLINE# #UNINDENT# self . hidden_columns |= self . model . hidden_columns #NEWLINE# if isinstance ( self . active_fields , basestring ) : #NEWLINE# #INDENT# self . active_fields = frozenset ( fields . fields_list ( self . model , self . active_fields ) ) #NEWLINE# #UNINDENT# self . active_fields |= self . model . active_fields #NEWLINE# self . hidden_elements |= self . model . hidden_elements #NEWLINE# for b in self . model . mro ( ) : #NEWLINE# #INDENT# for ( k , v ) in list ( b . __dict__ . items ( ) ) : #NEWLINE# #INDENT# if isinstance ( v , actions . Action ) : #NEWLINE# #INDENT# existing_value = self . __dict__ . get ( k , NOT_PROVIDED ) #NEWLINE# if ( existing_value is NOT_PROVIDED ) : #NEWLINE# #INDENT# setattr ( self , k , v ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( existing_value is None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( existing_value , actions . Action ) ) : #NEWLINE# #INDENT# raise Exception ( ( '%s cannot install model action %s because name is already used for %r' % self ) , k , existing_value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for name in ( 'workflow_state_field' , 'workflow_owner_field' ) : #NEWLINE# #INDENT# if ( getattr ( fieldname , name ) is None ) : #NEWLINE# #INDENT# setattr ( self , name , getattr ( self . model , name ) ) #NEWLINE# #UNINDENT# #UNINDENT# for name in ( 'handle_uploaded_files' , ) : #NEWLINE# #INDENT# if ( getattr ( self , name ) is None ) : #NEWLINE# #INDENT# m = getattr ( self . model , name , None ) #NEWLINE# if ( m is not None ) : #NEWLINE# #INDENT# setattr ( self , name , model2actor ( m ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . master_key : #NEWLINE# #INDENT# master_model = None #NEWLINE# try : #NEWLINE# #INDENT# fk = self . model . _meta . get_field ( self . master_key ) #NEWLINE# if ( fk . rel is not None ) : #NEWLINE# #INDENT# master_model = fk . rel . model #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( fk , ChoiceListField ) : #NEWLINE# #INDENT# master_model = fk . choicelist . item_class #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( fk , GenericForeignKey ) : #NEWLINE# #INDENT# master_model = ContentType #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Unsupported master_key {0} ({1})' . format ( fk , fk . __class__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except models . FieldDoesNotExist : #NEWLINE# #INDENT# for vf in self . model . _meta . virtual_fields : #NEWLINE# #INDENT# if ( vf . name == self . master_key ) : #NEWLINE# #INDENT# fk = vf #NEWLINE# master_model = ContentType #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( master_model is None ) : #NEWLINE# #INDENT# df = getattr ( self . model , self . master_key , None ) #NEWLINE# if ( df is None ) : #NEWLINE# #INDENT# msg = "No field '{0}' in {1}" . format ( self . master_key , self . model ) #NEWLINE# raise Exception ( INVALID_MK . format ( self . master_key , self , msg ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( df , fields . DummyField ) : #NEWLINE# #INDENT# self . abstract = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = 'Cannot handle master key {0}' . format ( df ) #NEWLINE# msg += ' (20150820 virtual fields: {0})' . format ( [ vf . name for vf in self . model . _meta . virtual_fields ] ) #NEWLINE# raise Exception ( INVALID_MK . format ( self . master_key , self , msg ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . master = master_model #NEWLINE# self . master_field = fk #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# super ( Table , self ) . class_init ( ) #NEWLINE# if ( self . order_by is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( self . order_by , ( list , tuple ) ) ) : #NEWLINE# #INDENT# raise Exception ( ( '%s.order_by is %r (must be a list or tuple)' % ( self , self . order_by ) ) ) #NEWLINE# #UNINDENT# if False : #NEWLINE# #INDENT# for fieldname in self . order_by : #NEWLINE# #INDENT# if fieldname . startswith ( '-' ) : #NEWLINE# #INDENT# fieldname = fieldname [ 1 : ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ( fk , remote , direct , m2m ) = self . model . _meta . get_field_by_name ( fieldname ) #NEWLINE# assert direct #NEWLINE# assert ( not m2m ) #NEWLINE# #UNINDENT# except models . FieldDoesNotExist : #NEWLINE# #INDENT# raise Exception ( ( 'Unknown fieldname %r in %s.order_by' % ( fieldname , self ) ) )