def selected(self): """ Values returned by this method are displayed in select box It should return locations passed in GET parameters without their descendants :return: Selected locations without their descendants """ location_ids = self.request.GET.getlist(self.slug) if len(location_ids) == 0 \ and not self.request.couch_user.has_permission(self.request.domain, 'access_all_locations'): # Display the user's location in the filter if none is selected location_ids = self.request.couch_user.get_location_ids( self.request.domain) choice_provider = LocationChoiceProvider( StubReport(domain=self.domain), None) # We don't include descendants here because they will show up in select box choice_provider.configure({'include_descendants': False}) choices = choice_provider.get_choices_for_known_values( location_ids, self.request.couch_user) if not choices: return self.default_options else: return [{ 'id': choice.value, 'text': choice.display } for choice in choices]
def get_value(cls, request, domain): selected = super(EnikshayLocationFilter, cls).get_value(request, domain) choice_provider = LocationChoiceProvider(StubReport(domain=domain), None) choice_provider.configure({'include_descendants': True}) return [ choice.value for choice in choice_provider.get_choices_for_known_values(selected) ]
def get_value(cls, request, domain): selected = super(EnikshayLocationFilter, cls).get_value(request, domain) choice_provider = LocationChoiceProvider(StubReport(domain=domain), None) choice_provider.configure({'include_descendants': True}) return [ choice.value for choice in choice_provider.get_choices_for_known_values(selected) ]
def selected(self): selected = super(EnikshayLocationFilter, self).selected choice_provider = LocationChoiceProvider( StubReport(domain=self.domain), None) choice_provider.configure({'include_descendants': True}) return [{ 'id': location.value, 'text': location.display } for location in choice_provider.get_choices_for_known_values( selected)]
def get_value(cls, request, domain): selected = super(EnikshayLocationFilter, cls).get_value(request, domain) if len(filter(None, selected)) == 0 and not request.couch_user.has_permission(domain, 'access_all_locations'): # Force the user to select their assigned locations, otherwise selecting no locations will result in # all results being returned. selected = request.couch_user.get_location_ids(domain) choice_provider = LocationChoiceProvider(StubReport(domain=domain), None) choice_provider.configure({'include_descendants': True}) selected_locations = [ choice.value for choice in choice_provider.get_choices_for_known_values(selected, request.couch_user) ] return selected_locations
def selected(self): """ Values returned by this method are displayed in select box It should return locations passed in GET parameters without their descendants :return: Selected locations without their descendants """ location_ids = self.request.GET.getlist(self.slug) choice_provider = LocationChoiceProvider(StubReport(domain=self.domain), None) # We don't include descendants here because they will show up in select box choice_provider.configure({'include_descendants': False}) choices = choice_provider.get_choices_for_known_values(location_ids) if not choices: return self.default_options else: return [ {'id': choice.value, 'text': choice.display} for choice in choices ]
def selected(self): """ Values returned by this method are displayed in select box It should return locations passed in GET parameters without their descendants :return: Selected locations without their descendants """ location_ids = self.request.GET.getlist(self.slug) choice_provider = LocationChoiceProvider( StubReport(domain=self.domain), None) # We don't include descendants here because they will show up in select box choice_provider.configure({'include_descendants': False}) choices = choice_provider.get_choices_for_known_values(location_ids) if not choices: return self.default_options else: return [{ 'id': choice.value, 'text': choice.display } for choice in choices]