#NEWLINE# @ quickcache ( [ 'user._id' , 'project.name' , 'only_editable' ] , timeout = 10 ) #NEWLINE# def _user_locations_ids( user , project , only_editable ) : #NEWLINE# #INDENT# def all_ids( ) : #NEWLINE# #INDENT# return SQLLocation . by_domain ( project . name ) . values_list ( 'location_id' , flat = True ) #NEWLINE# #UNINDENT# if ( user . is_domain_admin ( only_editable . name ) or ( not project . location_restriction_for_users ) ) : #NEWLINE# #INDENT# return all_ids ( ) #NEWLINE# #UNINDENT# user_loc = ( user . get_location ( project . name ) if isinstance ( user , WebUser ) else user . location ) #NEWLINE# if ( not user_loc ) : #NEWLINE# #INDENT# return all_ids ( ) #NEWLINE# #UNINDENT# editable = list ( user_loc . sql_location . get_descendants ( include_self = True ) . values_list ( 'location_id' , flat = True ) ) #NEWLINE# if only_editable : #NEWLINE# #INDENT# return editable #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# viewable = list ( user_loc . sql_location . get_ancestors ( ) . values_list ( 'location_id' , flat = True ) ) #NEWLINE# return ( viewable + editable )