示例#1
0
    def retrieve(self, request, *args, **kwargs):
        if (getattr(request, 'API_VERSION', None) > 1
            and request.REGION == mkt.regions.RESTOFWORLD):
            # In API v2 and onwards, geoip is not done automatically, so we
            # need to do it ourselves.
            region_middleware = mkt.regions.middleware.RegionMiddleware()
            user_region = region_middleware.region_from_request(request)
            region_middleware.store_region(request, user_region)

        # List of active switch names.
        switches = [str(s) for s in
                    Switch.objects.filter(active=True)
                    .values_list('name', flat=True)]

        data = {
            'region': request.REGION.slug,
            'waffle': {
                'switches': switches,
            }
        }
        if request.user.is_authenticated():
            data['apps'] = user_relevant_apps(request.user)
        if switch_is_active('firefox-accounts'):
            data['fxa_auth_state'], data['fxa_auth_url'] = fxa_auth_info()

        # Return an HttpResponse directly to be as fast as possible.
        return Response(data)
示例#2
0
    def retrieve(self, request, *args, **kwargs):
        data = {'region': request.REGION.slug}
        if request.amo_user:
            data['apps'] = user_relevant_apps(request.amo_user)

        # Return an HttpResponse directly to be as fast as possible.
        return HttpResponse(json.dumps(data),
                            content_type='application/json; charset=utf-8')
示例#3
0
    def retrieve(self, request, *args, **kwargs):
        data = {
            'region': request.REGION.slug
        }
        if request.amo_user:
          data['apps'] = user_relevant_apps(request.amo_user)

        # Return an HttpResponse directly to be as fast as possible.
        return HttpResponse(json.dumps(data),
                            content_type='application/json; charset=utf-8')
示例#4
0
文件: views.py 项目: ujdhesa/zamboni
    def retrieve(self, request, *args, **kwargs):
        if getattr(request, "API_VERSION", None) > 1 and request.REGION == mkt.regions.RESTOFWORLD:
            # In API v2 and onwards, geoip is not done automatically, so we
            # need to do it ourselves.
            region_middleware = mkt.regions.middleware.RegionMiddleware()
            user_region = region_middleware.region_from_request(request)
            region_middleware.store_region(request, user_region)

        data = {"region": request.REGION.slug}
        if request.user.is_authenticated():
            data["apps"] = user_relevant_apps(request.user)
            data["enable_recommendations"] = request.user.enable_recommendations

        # Return an HttpResponse directly to be as fast as possible.
        return Response(data)
示例#5
0
    def retrieve(self, request, *args, **kwargs):
        if (getattr(request, 'API_VERSION', None) > 1
            and request.REGION == mkt.regions.RESTOFWORLD):
            # In API v2 and onwards, geoip is not done automatically, so we
            # need to do it ourselves.
            region_middleware = mkt.regions.middleware.RegionMiddleware()
            user_region = region_middleware.region_from_request(request)
            region_middleware.store_region(request, user_region)

        data = {
            'region': request.REGION.slug,
        }
        if request.user.is_authenticated():
            data['apps'] = user_relevant_apps(request.user)
            data['enable_recommendations'] = request.user.enable_recommendations

        # Return an HttpResponse directly to be as fast as possible.
        return Response(data)
示例#6
0
文件: views.py 项目: anushbmx/zamboni
    def retrieve(self, request, *args, **kwargs):

        # List of active switch names.
        switches = [str(s) for s in
                    Switch.objects.filter(active=True)
                    .values_list('name', flat=True)]

        data = {
            'region': request.REGION.slug,
            'waffle': {
                'switches': switches,
            }
        }
        if request.amo_user:
            data['apps'] = user_relevant_apps(request.amo_user)
        if switch_is_active('firefox-accounts'):
            data['fxa_auth_state'], data['fxa_auth_url'] = fxa_auth_info()

        # Return an HttpResponse directly to be as fast as possible.
        return Response(data)