#NEWLINE# @ require_enabled #NEWLINE# def save_site( self , site , add_role = True ) : #NEWLINE# #INDENT# if ( not site . tenant_id ) : #NEWLINE# #INDENT# tenant = self . driver . create_tenant ( tenant_name = site . login_base , description = site . name , enabled = site . enabled ) #NEWLINE# site . tenant_id = tenant . id #NEWLINE# self . driver . add_user_role ( self . caller . kuser_id , tenant . id , 'admin' ) #NEWLINE# #UNINDENT# if ( site . id and site . tenant_id ) : #NEWLINE# #INDENT# self . driver . update_tenant ( site . tenant_id , description = site . name , enabled = tenant . enabled ) #NEWLINE# #UNINDENT# site . save ( ) #NEWLINE# site . enacted = datetime . now ( ) #NEWLINE# site . save ( update_fields = [ 'enacted' ] )