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)
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')
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')
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)
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)
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)