def debug(request, addon): if not settings.DEBUG: raise http.Http404 context = { 'app': addon, 'inapps': [], 'urls': { 'es': '%s/apps/webapp/%s' % (settings.ES_URLS[0], addon.pk) }, } if addon.is_premium(): context['app_jwt'] = _prepare_pay(request, addon)['webpayJWT'] for inapp in addon.inappproduct_set.all(): contribution = Contribution.objects.create( addon=addon, inapp_product=inapp, ) context['inapps'].append({ 'inapp': inapp, 'jwt': get_product_jwt( InAppProduct(inapp), contribution, )['webpayJWT'], }) return render(request, 'developers/debug.html', context)
def debug(request, addon): if not settings.DEBUG: raise http.Http404 context = { 'app': addon, 'inapps': [], 'urls': {'es': '%s/apps/webapp/%s' % (settings.ES_URLS[0], addon.pk)}, } if addon.is_premium(): context['app_jwt'] = _prepare_pay(request, addon)['webpayJWT'] for inapp in addon.inappproduct_set.all(): contribution = Contribution.objects.create( addon=addon, inapp_product=inapp, ) context['inapps'].append({ 'inapp': inapp, 'jwt': get_product_jwt( InAppProduct(inapp), contribution, )['webpayJWT'], }) return render(request, 'developers/debug.html', context)
def obj_create(self, bundle, request, **kwargs): region = getattr(request, 'REGION', None) if region and region.id not in settings.PURCHASE_ENABLED_REGIONS: log.info('Region {0} is not in {1}' .format(region.id, settings.PURCHASE_ENABLED_REGIONS)) if not waffle.flag_is_active(request, 'allow-paid-app-search'): log.info('Flag not active') raise http_error(http.HttpForbidden, 'Not allowed to purchase for this flag') bundle.obj = GenericObject(_prepare_pay(request, bundle.data['app'])) return bundle
def obj_create(self, bundle, request, **kwargs): region = getattr(request, 'REGION', None) if region and region.id not in settings.PURCHASE_ENABLED_REGIONS: log.info('Region {0} is not in {1}'.format( region.id, settings.PURCHASE_ENABLED_REGIONS)) if not waffle.flag_is_active(request, 'allow-paid-app-search'): log.info('Flag not active') raise http_error(http.HttpForbidden, 'Not allowed to purchase for this flag') bundle.obj = GenericObject(_prepare_pay(request, bundle.data['app'])) return bundle
def obj_create(self, bundle, request, **kwargs): region = getattr(request, 'REGION', None) app = bundle.data['app'] if region and region.id not in app.get_price_region_ids(): log.info('Region {0} is not in {1}' .format(region.id, app.get_price_region_ids())) if payments_enabled(request): log.info('Flag not active') raise http_error(http.HttpForbidden, 'Payments are limited and flag not enabled') bundle.obj = GenericObject(_prepare_pay(request, bundle.data['app'])) return bundle
def obj_create(self, bundle, request, **kwargs): region = getattr(request, 'REGION', None) app = bundle.data['app'] if region and region.id not in app.get_price_region_ids(): log.info('Region {0} is not in {1}'.format( region.id, app.get_price_region_ids())) if payments_enabled(request): log.info('Flag not active') raise http_error(http.HttpForbidden, 'Payments are limited and flag not enabled') bundle.obj = GenericObject(_prepare_pay(request, bundle.data['app'])) return bundle
def post(self, request, *args, **kwargs): form = PrepareForm(request.DATA) if not form.is_valid(): return Response(form.errors, status=status.HTTP_400_BAD_REQUEST) app = form.cleaned_data['app'] region = getattr(request, 'REGION', None) if region and region.id not in app.get_price_region_ids(): log.info('Region {0} is not in {1}' .format(region.id, app.get_price_region_ids())) return Response('Payments are limited and flag not enabled', status=status.HTTP_403_FORBIDDEN) try: data = _prepare_pay(request._request, app) except AlreadyPurchased: return Response({'reason': u'Already purchased app.'}, status=status.HTTP_409_CONFLICT) return Response(data, status=status.HTTP_201_CREATED)
def obj_create(self, bundle, request, **kwargs): bundle.obj = GenericObject(_prepare_pay(request, bundle.data['app'])) return bundle