Esempio n. 1
0
    def get_addons(self, obj):
        request = self.context.get('request')
        if isinstance(request, DRFRequest):
            # rest framework wraps the underlying Request
            real_request = request._request
        else:
            real_request = request
        orginal_get = real_request.GET
        real_request.GET = real_request.GET.copy()

        if obj.endpoint in (Shelf.Endpoints.SEARCH,
                            Shelf.Endpoints.RANDOM_TAG):
            request.GET.update(obj.get_param_dict())
            addons = AddonSearchView(request=request).get_data(obj.get_count())
        elif obj.endpoint == Shelf.Endpoints.COLLECTIONS:
            kwargs = {
                'user_pk': str(settings.TASK_USER_ID),
                'collection_slug': obj.criteria,
            }
            collection_addons = CollectionAddonViewSet(request=request,
                                                       action='list',
                                                       kwargs=kwargs).get_data(
                                                           obj.get_count())
            addons = [
                item['addon'] for item in collection_addons if 'addon' in item
            ]
        else:
            addons = []

        real_request.GET = orginal_get
        return addons
Esempio n. 2
0
 def get_addons(self, obj):
     if obj.endpoint == 'search':
         criteria = obj.criteria.strip('?')
         params = dict(parse.parse_qsl(criteria))
         request = self.context.get('request')
         tmp = request.GET
         request.GET = request.GET.copy()
         request.GET.update(params)
         addons = AddonSearchView(request=request).data
         request.GET = tmp
         return addons
     elif obj.endpoint == 'collections':
         request = self.context.get('request')
         kwargs = {
             'user_pk': str(settings.TASK_USER_ID),
             'collection_slug': obj.criteria,
         }
         collection_addons = CollectionAddonViewSet(request=request,
                                                    action='list',
                                                    kwargs=kwargs).data
         return [
             item['addon'] for item in collection_addons if 'addon' in item
         ]
     else:
         return None
Esempio n. 3
0
    def get_addons(self, obj):
        request = self.context.get('request')
        if isinstance(request, DRFRequest):
            # rest framework wraps the underlying Request
            real_request = request._request
        else:
            real_request = request
        orginal_get = real_request.GET
        real_request.GET = real_request.GET.copy()

        if obj.endpoint in ('search', 'search-themes'):
            criteria = obj.criteria.strip('?')
            params = dict(parse.parse_qsl(criteria))
            request.GET.update(params)
            addons = AddonSearchView(request=request).get_data(obj.get_count())
        elif obj.endpoint == 'collections':
            kwargs = {
                'user_pk': str(settings.TASK_USER_ID),
                'collection_slug': obj.criteria,
            }
            collection_addons = CollectionAddonViewSet(request=request,
                                                       action='list',
                                                       kwargs=kwargs).get_data(
                                                           obj.get_count())
            addons = [
                item['addon'] for item in collection_addons if 'addon' in item
            ]
        else:
            addons = None

        real_request.GET = orginal_get
        return addons
Esempio n. 4
0
 def get_addons(self, obj):
     if obj.endpoint == 'search':
         criteria = obj.criteria.strip('?')
         params = dict(parse.parse_qsl(criteria))
         request = self.context.get('request', None)
         request.GET = request.GET.copy()
         request.GET.update(params)
         return AddonSearchView(request=request).data
     else:
         return None
Esempio n. 5
0
    def search(self):
        self.reindex(Addon)

        qs = AddonSearchView().get_queryset()
        return qs.filter('term', id=self.addon.pk).execute()[0]
Esempio n. 6
0
    def search(self):
        self.reindex(Addon)

        qs = AddonSearchView().get_queryset()
        return qs.filter('term', id=self.addon.pk).execute()[0]