Esempio n. 1
0
    def retrieve(self, request, *args, **kwargs):
        query = kwargs['query']
        user_ids = []
        query = query.replace("+", " ")
        query_error, results = get_search_results(query)
        for unserialized_user in results:
            user_ids.append(unserialized_user.id)

        queryset = User.objects.filter(pk__in=user_ids)
        users = self.paginate_queryset(queryset)

        response = []
        for user in users:
            if user.is_student:
                response.append(
                    StudentSerializer(user, context={
                        'request': request
                    }).data)
            else:
                response.append(
                    CounselorTeacherSerializer(user,
                                               context={
                                                   'request': request
                                               }).data)

        return self.get_paginated_response(response)
Esempio n. 2
0
File: api.py Progetto: czhao39/ion
    def retrieve(self, request, *args, **kwargs):
        query = kwargs['query']
        user_ids = []
        query = query.replace("+", " ")
        query_error, results = get_search_results(query)
        for unserialized_user in results:
            user_ids.append(unserialized_user.id)

        queryset = User.objects.filter(pk__in=user_ids)
        users = self.paginate_queryset(queryset)

        response = []
        for user in users:
            if user.is_student:
                response.append(StudentSerializer(user, context={'request': request}).data)
            else:
                response.append(CounselorTeacherSerializer(user, context={'request': request}).data)

        return self.get_paginated_response(response)