예제 #1
0
 def _user_query(self, search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=self.domain,
         search_string=search_string,
         offset=page * limit,
         limit=limit)
     return user_es.mobile_users()
예제 #2
0
 def query(self, query_context):
     user_es = get_search_users_in_domain_es_query(
         self.domain,
         query_context.query,
         limit=query_context.limit,
         offset=query_context.offset)
     return self.get_choices_from_es_query(user_es)
예제 #3
0
 def _user_query(self, search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=self.domain, search_string=search_string,
         offset=page * limit, limit=limit)
     if not self.can_access_all_locations:
         loc_ids = (SQLLocation.objects.accessible_to_user(self.domain, self.couch_user)
                                       .location_ids())
         user_es = user_es.location(list(loc_ids))
     return user_es.mobile_users()
예제 #4
0
 def _user_query(self, search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=self.domain, search_string=search_string,
         offset=page * limit, limit=limit)
     if not self.can_access_all_locations:
         loc_ids = (SQLLocation.objects.accessible_to_user(self.domain, self.couch_user)
                                       .location_ids())
         user_es = user_es.location(list(loc_ids))
     return user_es.mobile_users()
예제 #5
0
 def _user_query(search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=domain, search_string=search_string,
         offset=page * limit, limit=limit)
     if not request.couch_user.has_permission(domain, 'access_all_locations'):
         loc_ids = (SQLLocation.objects.accessible_to_user(domain, request.couch_user)
                                       .location_ids())
         user_es = user_es.location(list(loc_ids))
     return user_es.mobile_users()
예제 #6
0
 def _user_query(search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=domain, search_string=search_string,
         offset=page * limit, limit=limit)
     if not request.couch_user.has_permission(domain, 'access_all_locations'):
         loc_ids = (SQLLocation.objects.accessible_to_user(domain, request.couch_user)
                                       .location_ids())
         user_es = user_es.location(list(loc_ids))
     return user_es.mobile_users()
예제 #7
0
 def schedule_user_recipients_response(self):
     domain = self.request.domain
     query = self.data.get('searchString')
     users = get_search_users_in_domain_es_query(domain, query, 10, 0)
     users = users.mobile_users().source(('_id', 'base_username')).run().hits
     ret = [
         {'id': user['_id'], 'text': user['base_username']}
         for user in users
     ]
     return ret
예제 #8
0
 def schedule_user_recipients_response(self):
     domain = self.request.domain
     query = self.data.get('searchString')
     users = get_search_users_in_domain_es_query(domain, query, 10, 0)
     users = users.mobile_users().source(('_id', 'base_username')).run().hits
     ret = [
         {'id': user['_id'], 'text': user['base_username']}
         for user in users
     ]
     return ret
예제 #9
0
 def get(self, request, domain):
     q = self.request.GET.get('q', None)
     users_query = (get_search_users_in_domain_es_query(domain, q, self._page_limit(), self._offset())
         .show_inactive()
         .remove_default_filter("not_deleted")
         .source("username")
     )
     values = [x['username'].split("@")[0] for x in users_query.run().hits]
     count = users_query.count()
     return self.render_json_response({
         'results': [{'id': v, 'text': v} for v in values],
         'total': count,
     })
예제 #10
0
파일: api.py 프로젝트: kkrampa/commcare-hq
 def get(self, request, domain):
     q = self.request.GET.get('q', None)
     users_query = (get_search_users_in_domain_es_query(domain, q, self._page_limit(), self._offset())
         .show_inactive()
         .remove_default_filter("not_deleted")
         .source("username")
     )
     values = [x['username'].split("@")[0] for x in users_query.run().hits]
     count = users_query.count()
     return self.render_json_response({
         'results': [{'id': v, 'text': v} for v in values],
         'total': count,
     })
예제 #11
0
 def query_count(self, query, user=None):
     user_es = get_search_users_in_domain_es_query(self.domain,
                                                   query,
                                                   limit=0,
                                                   offset=0)
     return user_es.run().total
예제 #12
0
 def _user_query(self, search_string, page, limit):
     user_es = get_search_users_in_domain_es_query(
         domain=self.domain, search_string=search_string,
         offset=page * limit, limit=limit)
     return user_es.mobile_users()
예제 #13
0
 def query_count(self, query, user=None):
     user_es = get_search_users_in_domain_es_query(self.domain, query, limit=0, offset=0)
     return user_es.run().total
예제 #14
0
 def query(self, query_context):
     user_es = get_search_users_in_domain_es_query(
         self.domain, query_context.query,
         limit=query_context.limit, offset=query_context.offset)
     return self.get_choices_from_es_query(user_es)