Ejemplo n.º 1
0
    def case_owners(self):
        """
        For unrestricted user
        :return:
        user ids for selected user types
        for selected reporting group ids, returns user_ids belonging to these groups
            also finds the sharing groups which has any user from the above reporting group
        selected sharing group ids
        selected user ids
            also finds the sharing groups which has any user from the above selected users
            ids and descendants ids of assigned locations to these users
        ids and descendants ids of selected locations
            assigned users at selected locations and their descendants

        For restricted user
        :return:
        selected user ids
            also finds the sharing groups which has any user from the above selected users
            ids and descendants ids of assigned locations to these users
        ids and descendants ids of selected locations
            assigned users at selected locations and their descendants
        """
        # Get user ids for each user that match the demo_user, admin,
        # Unknown Users, or All Mobile Workers filters
        mobile_user_and_group_slugs = self.request.GET.getlist(EMWF.slug)
        return get_case_owners(self.request, self.domain, mobile_user_and_group_slugs)
Ejemplo n.º 2
0
    def case_owners(self):
        """
        For unrestricted user
        :return:
        user ids for selected user types
        for selected reporting group ids, returns user_ids belonging to these groups
            also finds the sharing groups which has any user from the above reporting group
        selected sharing group ids
        selected user ids
            also finds the sharing groups which has any user from the above selected users
            ids and descendants ids of assigned locations to these users
        ids and descendants ids of selected locations
            assigned users at selected locations and their descendants

        For restricted user
        :return:
        selected user ids
            also finds the sharing groups which has any user from the above selected users
            ids and descendants ids of assigned locations to these users
        ids and descendants ids of selected locations
            assigned users at selected locations and their descendants
        """
        # Get user ids for each user that match the demo_user, admin,
        # Unknown Users, or All Mobile Workers filters
        mobile_user_and_group_slugs = self.request.GET.getlist(EMWF.slug)
        return get_case_owners(self.request, self.domain, mobile_user_and_group_slugs)
Ejemplo n.º 3
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (EMWF.show_all_data(
                self.value) or EMWF.no_filters_selected(self.value)):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(
                self.value):
            return query_all_project_data(query, self.domain, self.value)

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(
                self.value):
            return query_deactivated_data(query, self.domain)

        # otherwise only return explicit matches
        case_owners = get_case_owners(self.request, self.domain, self.value)
        return query.owner(case_owners)
Ejemplo n.º 4
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (
            EMWF.show_all_data(self.value)
            or EMWF.no_filters_selected(self.value)
        ):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(self.value):
            return query_all_project_data(query, self.domain, self.value)

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(self.value):
            return query_deactivated_data(query, self.domain)

        # otherwise only return explicit matches
        case_owners = get_case_owners(self.request, self.domain, self.value)
        return query.owner(case_owners)
Ejemplo n.º 5
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (
            EMWF.show_all_data(self.value)
            or EMWF.no_filters_selected(self.value)
        ):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(self.value):
            return query.filter(all_project_data_filter(self.domain, self.value))

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(self.value):
            return query.filter(deactivated_case_owners(self.domain))

        selected_user_types = [v['id'] for v in self.value]
        case_owners = get_case_owners(self.request, self.domain, selected_user_types)
        return query.owner(case_owners)
Ejemplo n.º 6
0
 def case_owners(self):
     mobile_user_and_group_slugs = self.request.GET.getlist(EMWF.slug)
     return get_case_owners(self.request, self.domain,
                            mobile_user_and_group_slugs)