#NEWLINE# @ staticmethod #NEWLINE# def select_by_user( user ) : #NEWLINE# #INDENT# if user . is_admin : #NEWLINE# #INDENT# qs = User . objects . all ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# from core.models.site import SitePrivilege #NEWLINE# site_privs = SitePrivilege . objects . filter ( user = user ) #NEWLINE# sites = [ sp . site for sp in site_privs if ( sp . role . role in [ 'Admin' , 'admin' , 'pi' ] ) ] #NEWLINE# site_privs = SitePrivilege . objects . filter ( site__in = sites ) #NEWLINE# user_ids = ( [ sp . user . id for sp in site_privs ] + [ user . id ] ) #NEWLINE# qs = User . objects . filter ( ( Q ( site__in = sites ) | Q ( id__in = user_ids ) ) ) #NEWLINE# #UNINDENT# return qs