当前位置: 首页>>代码示例>>Python>>正文


Python models.HQUserType类代码示例

本文整理汇总了Python中corehq.apps.reports.models.HQUserType的典型用法代码示例。如果您正苦于以下问题:Python HQUserType类的具体用法?Python HQUserType怎么用?Python HQUserType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HQUserType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: es_query

    def es_query(self):
        if not getattr(self, 'es_response', None):
            q = {
                "query": {
                    "range": {
                        self.time_field: {
                            "from": self.datespan.startdate_param,
                            "to": self.datespan.enddate_param,
                            "include_upper": False}}},
                "filter": {"and": ADD_TO_ES_FILTER["forms"][:]}}

            xmlnss = filter(None, [f["xmlns"] for f in self.all_relevant_forms.values()])
            if xmlnss:
                q["filter"]["and"].append({"terms": {"xmlns.exact": xmlnss}})

            users_data = ExpandedMobileWorkerFilter.pull_users_and_groups(self.domain, self.request, True, True)
            if "t__0" not in self.request.GET.getlist("emw") or users_data["admin_and_demo_users"]:
                q["filter"]["and"].append(
                    {"terms": {"form.meta.userID": filter(None, [u["user_id"] for u in users_data["combined_users"]])}})
            else:
                negated_ids = util.get_all_users_by_domain(self.domain, user_filter=HQUserType.all_but_users(), simplified=True)
                ids = filter(None, [user['user_id'] for user in negated_ids])
                q["filter"]["and"].append({"not": {"terms": {"form.meta.userID": ids}}})

            for cp in filter(None, self.request.GET.get('form_data', "").split(",")):
                q["filter"]["and"].append({"term": {"__props_for_querying": cp.lower()}})

            q["sort"] = self.get_sorting_block() if self.get_sorting_block() else [{self.time_field : {"order": "desc"}}]
            self.es_response = es_query(params={"domain.exact": self.domain}, q=q, es_url=XFORM_INDEX + '/xform/_search',
                start_at=self.pagination.start, size=self.pagination.count)
        return self.es_response
开发者ID:wpride,项目名称:commcare-hq,代码行数:31,代码来源:inspect.py

示例2: get_user_filter

 def get_user_filter(cls, request):
     ufilter = group = individual = None
     try:
         if request.GET.get('ufilter', ''):
             ufilter = request.GET.getlist('ufilter')
         group = request.GET.get('group', '')
         individual = request.GET.get('individual', '')
     except KeyError:
         pass
     show_filter = True
     toggle = HQUserType.use_defaults()
     if ufilter and not (group or individual):
         toggle = HQUserType.use_filter(ufilter)
     elif group or individual:
         show_filter = False
     return toggle, show_filter
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:16,代码来源:users.py

示例3: get_admins_and_demo_users

 def get_admins_and_demo_users(self, ufilters=None):
     ufilters = ufilters if ufilters is not None else ['1', '2', '3']
     users = self.get_all_users_by_domain(
         group=None,
         user_filter=tuple(HQUserType.use_filter(ufilters)),
         simplified=True
     ) if ufilters else []
     return users
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:8,代码来源:__init__.py

示例4: get_all_users_by_domain

def get_all_users_by_domain(domain=None, group=None, user_ids=None,
                            user_filter=None, simplified=False, CommCareUser=None, include_inactive=False):
    """
        WHEN THERE ARE A LOT OF USERS, THIS IS AN EXPENSIVE OPERATION.
        Returns a list of CommCare Users based on domain, group, and user 
        filter (demo_user, admin, registered, unknown)
    """
    user_ids = user_ids if user_ids and user_ids[0] else None
    if not CommCareUser:
        from corehq.apps.users.models import CommCareUser

    if group:
        # get all the users only in this group and don't bother filtering.
        if not isinstance(group, Group):
            group = Group.get(group)
        users = group.get_users(is_active=(not include_inactive), only_commcare=True)
    elif user_ids is not None:
        try:
            users = [CommCareUser.get_by_user_id(id) for id in user_ids]
        except Exception:
            users = []
        if users and users[0] is None:
            raise Http404()
    else:
        if not user_filter:
            user_filter = HQUserType.all()
        users = []
        submitted_user_ids = get_all_userids_submitted(domain)
        registered_user_ids = dict([(user.user_id, user) for user in CommCareUser.by_domain(domain)])
        if include_inactive:
            registered_user_ids.update(dict([(u.user_id, u) for u in CommCareUser.by_domain(domain, is_active=False)]))
        for user_id in submitted_user_ids:
            if user_id in registered_user_ids and user_filter[HQUserType.REGISTERED].show:
                user = registered_user_ids[user_id]
                users.append(user)
            elif not user_id in registered_user_ids and \
                 (user_filter[HQUserType.ADMIN].show or
                  user_filter[HQUserType.DEMO_USER].show or
                  user_filter[HQUserType.UNKNOWN].show):
                username = get_username_from_forms(domain, user_id)
                temp_user = TempCommCareUser(domain, username, user_id)
                if user_filter[temp_user.filter_flag].show:
                    users.append(temp_user)
        if user_filter[HQUserType.UNKNOWN].show:
            users.append(TempCommCareUser(domain, '*', None))

        if user_filter[HQUserType.REGISTERED].show:
            # now add all the registered users who never submitted anything
            for user_id in registered_user_ids:
                if not user_id in submitted_user_ids:
                    user = CommCareUser.get_by_user_id(user_id)
                    users.append(user)

    if simplified:
        return [_report_user_dict(user) for user in users]
    return users
开发者ID:aristide,项目名称:commcare-hq,代码行数:56,代码来源:util.py

示例5: report_context

 def report_context(self):
     context = super(CaseReassignmentInterface, self).report_context
     active_users = util.get_all_users_by_domain(self.domain, user_filter=HQUserType.use_defaults(), simplified=True)
     context.update(
         users=[dict(ownerid=user.get('user_id'), name=user.get('username_in_report'), type="user")
                for user in active_users],
         groups=[dict(ownerid=group.get_id, name=group.name, type="group")
                 for group in self.all_case_sharing_groups]
     )
     return context
开发者ID:mchampanis,项目名称:core-hq,代码行数:10,代码来源:interfaces.py

示例6: report_context

 def report_context(self):
     context = super(CaseReassignmentInterface, self).report_context
     active_users = self.get_all_users_by_domain(user_filter=tuple(HQUserType.all()), simplified=True)
     context.update(
         users=[dict(ownerid=user.user_id, name=user.username_in_report, type="user")
                for user in active_users],
         groups=[dict(ownerid=group.get_id, name=group.name, type="group")
                 for group in self.all_case_sharing_groups],
         user_ids=self.user_ids,
     )
     return context
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:11,代码来源:interfaces.py


注:本文中的corehq.apps.reports.models.HQUserType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。