コード例 #1
0
    def pull_users_and_groups(cls,
                              domain,
                              request,
                              simplified_users=False,
                              combined=False,
                              CommCareUser=CommCareUser):
        emws = request.GET.getlist(cls.slug)

        users = []
        user_ids = [u[3:] for u in filter(lambda s: s.startswith("u__"), emws)]
        if user_ids or "t__0" in emws:
            users = util.get_all_users_by_domain(domain=domain,
                                                 user_ids=user_ids,
                                                 simplified=simplified_users,
                                                 CommCareUser=CommCareUser)

        user_type_ids = [
            int(t[3:]) for t in filter(lambda s: s.startswith("t__"), emws)
        ]
        user_filter = tuple(
            [HQUserToggle(id, id in user_type_ids) for id in range(4)])
        other_users = util.get_all_users_by_domain(domain=domain,
                                                   user_filter=user_filter,
                                                   simplified=simplified_users,
                                                   CommCareUser=CommCareUser)

        group_ids = [
            g[3:] for g in filter(lambda s: s.startswith("g__"), emws)
        ]
        groups = [Group.get(g) for g in group_ids]

        all_users = users + other_users

        if combined:
            user_dict = {}
            for group in groups:
                user_dict["%s|%s" %
                          (group.name,
                           group._id)] = util.get_all_users_by_domain(
                               group=group, simplified=simplified_users)

            users_in_groups = [
                user for sublist in user_dict.values() for user in sublist
            ]

            users_by_group = user_dict
            combined_users = remove_dups(all_users + users_in_groups,
                                         "user_id")
        else:
            users_by_group = None
            combined_users = None
        return _UserData(
            users=all_users,
            admin_and_demo_users=other_users,
            groups=groups,
            users_by_group=users_by_group,
            combined_users=combined_users,
        )
コード例 #2
0
    def pull_users_and_groups(cls,
                              domain,
                              mobile_user_and_group_slugs,
                              include_inactive=False,
                              limit_user_ids=None):
        user_ids = set(cls.selected_user_ids(mobile_user_and_group_slugs))
        user_types = cls.selected_user_types(mobile_user_and_group_slugs)
        group_ids = cls.selected_group_ids(mobile_user_and_group_slugs)
        location_ids = cls.selected_location_ids(mobile_user_and_group_slugs)
        users = []

        if location_ids:
            user_ids |= set(
                user_ids_at_locations_and_descendants(location_ids))

        if limit_user_ids:
            user_ids = set(limit_user_ids).intersection(user_ids)

        if user_ids or HQUserType.REGISTERED in user_types:
            users = util.get_all_users_by_domain(
                domain=domain,
                user_ids=user_ids,
                simplified=True,
                CommCareUser=CommCareUser,
            )
        user_filter = tuple(
            [HQUserToggle(id, id in user_types) for id in range(4)])
        other_users = util.get_all_users_by_domain(
            domain=domain,
            user_filter=user_filter,
            simplified=True,
            CommCareUser=CommCareUser,
            include_inactive=include_inactive)
        groups = [Group.get(g) for g in group_ids]
        all_users = users + other_users

        user_dict = {}
        for group in groups:
            users_in_group = util.get_all_users_by_domain(group=group,
                                                          simplified=True)
            if limit_user_ids:
                users_in_group = filter(
                    lambda user: user['user_id'] in limit_user_ids,
                    users_in_group)
            user_dict["%s|%s" % (group.name, group._id)] = users_in_group

        users_in_groups = flatten_list(user_dict.values())
        users_by_group = user_dict
        combined_users = remove_dups(all_users + users_in_groups, "user_id")

        return _UserData(
            users=all_users,
            admin_and_demo_users=other_users,
            groups=groups,
            users_by_group=users_by_group,
            combined_users=combined_users,
        )
コード例 #3
0
ファイル: users.py プロジェクト: ekush/commcare-hq
 def pull_users_and_groups(cls,
                           domain,
                           request,
                           simplified_users=False,
                           combined=False,
                           CommCareUser=CommCareUser,
                           include_inactive=False):
     user_ids = cls.selected_user_ids(request)
     user_types = cls.selected_user_types(request)
     group_ids = cls.selected_group_ids(request)
     users = []
     if user_ids or HQUserType.REGISTERED in user_types:
         users = util.get_all_users_by_domain(
             domain=domain,
             user_ids=user_ids,
             simplified=simplified_users,
             CommCareUser=CommCareUser,
         )
     user_filter = tuple(
         [HQUserToggle(id, id in user_types) for id in range(4)])
     other_users = util.get_all_users_by_domain(
         domain=domain,
         user_filter=user_filter,
         simplified=simplified_users,
         CommCareUser=CommCareUser,
         include_inactive=include_inactive)
     groups = [Group.get(g) for g in group_ids]
     all_users = users + other_users
     if combined:
         user_dict = {}
         for group in groups:
             user_dict["%s|%s" %
                       (group.name,
                        group._id)] = util.get_all_users_by_domain(
                            group=group, simplified=simplified_users)
         users_in_groups = [
             user for sublist in user_dict.values() for user in sublist
         ]
         users_by_group = user_dict
         combined_users = remove_dups(all_users + users_in_groups,
                                      "user_id")
     else:
         users_by_group = None
         combined_users = None
     return _UserData(
         users=all_users,
         admin_and_demo_users=other_users,
         groups=groups,
         users_by_group=users_by_group,
         combined_users=combined_users,
     )
コード例 #4
0
ファイル: users.py プロジェクト: yonglehou/commcare-hq
    def pull_users_and_groups(cls, domain, mobile_user_and_group_slugs,
                              include_inactive=False, limit_user_ids=None):
        user_ids = cls.selected_user_ids(mobile_user_and_group_slugs)
        user_types = cls.selected_user_types(mobile_user_and_group_slugs)
        group_ids = cls.selected_group_ids(mobile_user_and_group_slugs)
        users = []

        if limit_user_ids:
            if not user_ids:
                user_ids = limit_user_ids
            else:
                user_ids = set(limit_user_ids).intersection(set(user_ids))

        if user_ids or HQUserType.REGISTERED in user_types:
            users = util.get_all_users_by_domain(
                domain=domain,
                user_ids=user_ids,
                simplified=True,
                CommCareUser=CommCareUser,
            )
        user_filter = tuple([HQUserToggle(id, id in user_types) for id in range(4)])
        other_users = util.get_all_users_by_domain(
            domain=domain,
            user_filter=user_filter,
            simplified=True,
            CommCareUser=CommCareUser,
            include_inactive=include_inactive
        )
        groups = [Group.get(g) for g in group_ids]
        all_users = users + other_users

        user_dict = {}
        for group in groups:
            user_dict["%s|%s" % (group.name, group._id)] = util.get_all_users_by_domain(
                group=group,
                simplified=True
            )
        users_in_groups = [user for sublist in user_dict.values() for user in sublist]
        users_by_group = user_dict
        combined_users = remove_dups(all_users + users_in_groups, "user_id")

        return _UserData(
            users=all_users,
            admin_and_demo_users=other_users,
            groups=groups,
            users_by_group=users_by_group,
            combined_users=combined_users,
        )
コード例 #5
0
    def pull_users_and_groups(cls, domain, mobile_user_and_group_slugs,
                              include_inactive=False, limit_user_ids=None):
        user_ids = cls.selected_user_ids(mobile_user_and_group_slugs)
        user_types = cls.selected_user_types(mobile_user_and_group_slugs)
        group_ids = cls.selected_group_ids(mobile_user_and_group_slugs)
        users = []

        if limit_user_ids:
            user_ids = set(limit_user_ids).intersection(set(user_ids))

        if user_ids or HQUserType.REGISTERED in user_types:
            users = util.get_all_users_by_domain(
                domain=domain,
                user_ids=user_ids,
                simplified=True,
                CommCareUser=CommCareUser,
            )
        user_filter = tuple([HQUserToggle(id, id in user_types) for id in range(4)])
        other_users = util.get_all_users_by_domain(
            domain=domain,
            user_filter=user_filter,
            simplified=True,
            CommCareUser=CommCareUser,
            include_inactive=include_inactive
        )
        groups = [Group.get(g) for g in group_ids]
        all_users = users + other_users

        user_dict = {}
        for group in groups:
            user_dict["%s|%s" % (group.name, group._id)] = util.get_all_users_by_domain(
                group=group,
                simplified=True
            )
        users_in_groups = flatten_list(user_dict.values())
        users_by_group = user_dict
        combined_users = remove_dups(all_users + users_in_groups, "user_id")

        return _UserData(
            users=all_users,
            admin_and_demo_users=other_users,
            groups=groups,
            users_by_group=users_by_group,
            combined_users=combined_users,
        )
コード例 #6
0
ファイル: users.py プロジェクト: amonkeykong81/commcare-hq
    def pull_users_and_groups(cls, domain, request, simplified_users=False, combined=False, CommCareUser=CommCareUser):
        emws = request.GET.getlist(cls.slug)

        users = []
        user_ids = [u[3:] for u in filter(lambda s: s.startswith("u__"), emws)]
        if user_ids or "t__0" in emws:
            users = util.get_all_users_by_domain(domain=domain, user_ids=user_ids, simplified=simplified_users,
                                                 CommCareUser=CommCareUser)

        user_type_ids = [int(t[3:]) for t in filter(lambda s: s.startswith("t__"), emws)]
        user_filter = tuple([HQUserToggle(id, id in user_type_ids) for id in range(4)])
        other_users = util.get_all_users_by_domain(domain=domain, user_filter=user_filter, simplified=simplified_users,
                                                   CommCareUser=CommCareUser)

        group_ids = [g[3:] for g in filter(lambda s: s.startswith("g__"), emws)]
        groups = [Group.get(g) for g in group_ids]

        all_users = users + other_users

        if combined:
            user_dict = {}
            for group in groups:
                user_dict["%s|%s" % (group.name, group._id)] = util.get_all_users_by_domain(
                    group=group,
                    simplified=simplified_users
                )

            users_in_groups = [user for sublist in user_dict.values() for user in sublist]

            users_by_group = user_dict
            combined_users = remove_dups(all_users + users_in_groups, "user_id")
        else:
            users_by_group = None
            combined_users = None
        return _UserData(
            users=all_users,
            admin_and_demo_users=other_users,
            groups=groups,
            users_by_group=users_by_group,
            combined_users=combined_users,
        )
コード例 #7
0
ファイル: users.py プロジェクト: aristide/commcare-hq
 def pull_users_and_groups(cls, domain, request, simplified_users=False,
         combined=False, CommCareUser=CommCareUser, include_inactive=False):
     user_ids = cls.selected_user_ids(request)
     user_types = cls.selected_user_types(request)
     group_ids = cls.selected_group_ids(request)
     users = []
     if user_ids or HQUserType.REGISTERED in user_types:
         users = util.get_all_users_by_domain(
             domain=domain,
             user_ids=user_ids,
             simplified=simplified_users,
             CommCareUser=CommCareUser,
         )
     user_filter = tuple([HQUserToggle(id, id in user_types) for id in range(4)])
     other_users = util.get_all_users_by_domain(domain=domain, user_filter=user_filter, simplified=simplified_users,
                                                CommCareUser=CommCareUser, include_inactive=include_inactive)
     groups = [Group.get(g) for g in group_ids]
     all_users = users + other_users
     if combined:
         user_dict = {}
         for group in groups:
             user_dict["%s|%s" % (group.name, group._id)] = util.get_all_users_by_domain(
                 group=group,
                 simplified=simplified_users
             )
         users_in_groups = [user for sublist in user_dict.values() for user in sublist]
         users_by_group = user_dict
         combined_users = remove_dups(all_users + users_in_groups, "user_id")
     else:
         users_by_group = None
         combined_users = None
     return _UserData(
         users=all_users,
         admin_and_demo_users=other_users,
         groups=groups,
         users_by_group=users_by_group,
         combined_users=combined_users,
     )