#NEWLINE# def find_supervisor( fses ) : #NEWLINE# #INDENT# '\n    find the admin who has the full control over all the flowspace elements in the\n    fses. It does this selection by finding the admin whose flowspace is a superset of\n    fses but is not a superviosr of another admin who also owns a flowspace that is\n    a superset of fses.\n    @param fses: the list of flowspaces we want to find an admin for\n    @type fses: list of FlowSpace objects\n    @return: the User object for the admin who has full control over fses\n    ' #NEWLINE# admins_list = UserProfile . objects . filter ( is_net_admin = True ) . order_by ( '-id' ) #NEWLINE# intersected_admins = [ ] #NEWLINE# intersected_supervisors = [ ] #NEWLINE# for admin in admins_list : #NEWLINE# #INDENT# adminfs = AdminFlowSpace . objects . filter ( user = admin . user ) #NEWLINE# if multifs_is_subset_of ( fses , adminfs ) : #NEWLINE# #INDENT# intersected_admins . append ( admin ) #NEWLINE# intersected_supervisors . append ( admin . supervisor ) #NEWLINE# #UNINDENT# #UNINDENT# selected_admin = None #NEWLINE# super_admin = None #NEWLINE# for admin in intersected_admins : #NEWLINE# #INDENT# if ( admin . user not in intersected_supervisors ) : #NEWLINE# #INDENT# selected_admin = admin #NEWLINE# break #NEWLINE# #UNINDENT# if ( admin . supervisor == admin . user ) : #NEWLINE# #INDENT# super_admin = admin #NEWLINE# #UNINDENT# #UNINDENT# if selected_admin : #NEWLINE# #INDENT# return selected_admin . user #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if super_admin : #NEWLINE# #INDENT# return super_admin . user #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None