<s> from django . utils . translation import ugettext as _ <EOL> from corehq . apps . locations . models import Location <EOL> def validate_report_parameters ( parameters , config ) : <EOL> for parameter in parameters : <EOL> if not parameter in config : <EOL> raise KeyError ( _ ( "<STR_LIT>" % parameter ) ) <EOL> def _is_location_CCT ( location ) : <EOL> return location . metadata . get ( "<STR_LIT>" , "<STR_LIT>" ) . lower ( ) == "<STR_LIT:true>" <EOL> def get_location_hierarchy_by_id ( location_id , domain , CCT_only = False ) : <EOL> if location_id is None or len ( location_id ) == <NUM_LIT:0> : <EOL> return [ location . get_id for location in Location . by_domain ( domain ) if not CCT_only or _is_location_CCT ( location ) ] <EOL> else : <EOL> user_location = Location . get ( location_id ) <EOL> locations = [ location . get_id for location in user_location . descendants if not CCT_only or _is_location_CCT ( location ) ] <EOL> if not CCT_only or _is_location_CCT ( user_location ) : <EOL> locations . insert ( <NUM_LIT:0> , user_location . get_id ) <EOL> return locations </s>
