def get_filters(self, selected): show_all = bool(not selected) values = fast_distinct_in_domain(DeviceReportEntry, self.field, self.domain) return [{ 'name': self.value_to_param(value), 'show': bool(show_all or value in selected) } for value in values]
def get_case_owner_ids(domain): from corehq.sql_db.util import get_db_aliases_for_partitioned_query db_aliases = get_db_aliases_for_partitioned_query() owner_ids = set() for db_alias in db_aliases: owner_ids.update(fast_distinct_in_domain(CommCareCaseSQL, 'owner_id', domain, using=db_alias)) return owner_ids
def filter_context(self): errors_only = bool(self.request.GET.get(self.errors_only_slug, False)) selected_tags = self.request.GET.getlist(self.slug) show_all = bool(not selected_tags) values = fast_distinct_in_domain(DeviceReportEntry, 'type', self.domain) tags = [{ 'name': value, 'show': bool(show_all or value in selected_tags) } for value in values] context = { 'errors_only_slug': self.errors_only_slug, 'default_on': show_all, 'logtags': tags, 'errors_css_id': 'device_log_errors_only_checkbox', self.errors_only_slug: errors_only, } return context
def _all_values(self): return fast_distinct_in_domain(DeviceReportEntry, 'type', self.domain)