def publisher_settings_pixel_edit(request, id): ''' View to allow a Publisher to edit a WebSite ''' from forms import PiggybackForm from atrinsic.base.models import Action pbPixel = get_object_or_404(request.organization.piggybackpixel_set, id=id) if request.method == 'POST': form = PiggybackForm(request.organization, request.POST) if form.is_valid(): ################## apeClient = Ape() ape_redirect_id = None getActions = Action.objects.filter( advertiser=form.cleaned_data['advertiser']).order_by('id') if getActions.count() == 0: # Do not create Pixel pass else: #Use RedirectID from Oldest Action(order_by('id')) and create actions under that RedirectID ape_redirect_id = getActions[0].ape_redirect_id # If script pixel, then we must create a piggy back # for both the JS Include(jsinclude), as well as the JS Code(content) if form.cleaned_data[ 'pixel_type'] == PIXEL_TYPE_SCRIPT and pbPixel.ape_include_pixel_id != 0: success, updatePixel = apeClient.execute_piggyback_update( request, ape_redirect_id, pbPixel.ape_include_pixel_id, form.cleaned_data['jsinclude']) #Call APE and create Piggyback Pixel with redirect determined above. success, createPixel = apeClient.execute_piggyback_update( request, ape_redirect_id, pbPixel.ape_content_pixel_id, form.cleaned_data['content']) pbPixel.advertiser = form.cleaned_data['advertiser'] pbPixel.pixel_type = form.cleaned_data['pixel_type'] pbPixel.jsinclude = form.cleaned_data['jsinclude'] pbPixel.content = form.cleaned_data['content'] pbPixel.save() return HttpResponseRedirect(reverse('publisher_piggyback_pixel')) else: inits = { 'advertiser': pbPixel.advertiser.pk, 'pixel_type': pbPixel.pixel_type, 'jsinclude': pbPixel.jsinclude, 'content': pbPixel.content, } form = PiggybackForm(request.organization, initial=inits) return AQ_render_to_response(request, 'publisher/settings/pixel-edit.html', { 'form': form, 'pixel': pbPixel }, context_instance=RequestContext(request))
def publisher_settings_pixel_edit(request, id): ''' View to allow a Publisher to edit a WebSite ''' from forms import PiggybackForm from atrinsic.base.models import Action pbPixel = get_object_or_404(request.organization.piggybackpixel_set, id=id) if request.method == 'POST': form = PiggybackForm(request.organization, request.POST) if form.is_valid(): ################## apeClient = Ape() ape_redirect_id = None getActions = Action.objects.filter(advertiser=form.cleaned_data['advertiser']).order_by('id') if getActions.count() == 0: # Do not create Pixel pass else: #Use RedirectID from Oldest Action(order_by('id')) and create actions under that RedirectID ape_redirect_id = getActions[0].ape_redirect_id # If script pixel, then we must create a piggy back # for both the JS Include(jsinclude), as well as the JS Code(content) if form.cleaned_data['pixel_type'] == PIXEL_TYPE_SCRIPT and pbPixel.ape_include_pixel_id != 0: success, updatePixel = apeClient.execute_piggyback_update(request,ape_redirect_id,pbPixel.ape_include_pixel_id,form.cleaned_data['jsinclude']) #Call APE and create Piggyback Pixel with redirect determined above. success, createPixel = apeClient.execute_piggyback_update(request,ape_redirect_id,pbPixel.ape_content_pixel_id,form.cleaned_data['content']) pbPixel.advertiser = form.cleaned_data['advertiser'] pbPixel.pixel_type = form.cleaned_data['pixel_type'] pbPixel.jsinclude=form.cleaned_data['jsinclude'] pbPixel.content = form.cleaned_data['content'] pbPixel.save() return HttpResponseRedirect(reverse('publisher_piggyback_pixel')) else: inits = { 'advertiser':pbPixel.advertiser.pk, 'pixel_type':pbPixel.pixel_type, 'jsinclude':pbPixel.jsinclude, 'content':pbPixel.content, } form = PiggybackForm(request.organization, initial=inits) return AQ_render_to_response(request, 'publisher/settings/pixel-edit.html', { 'form': form, 'pixel':pbPixel }, context_instance=RequestContext(request))
def publisher_settings_kenshoo_edit(request, id): ''' View to allow a Publisher to edit a WebSite ''' from forms import KenshooIntegrationEditForm from atrinsic.base.models import Action, Organization pbPixel = get_object_or_404(request.organization.kenshoointegration_set, id=id) if request.method == 'POST': form = KenshooIntegrationEditForm(request.organization, request.POST) advertiserID = request.POST.get("advertiser",None) if form.is_valid(): apeClient = Ape() ape_redirect_id = None getActions = Action.objects.filter(advertiser=Organization.objects.get(id=advertiserID)).order_by('id') if getActions.count() == 0: pass else: ape_redirect_id = getActions[0].ape_redirect_id success, createPixel = apeClient.execute_piggyback_update(request,ape_redirect_id,pbPixel.ape_content_pixel_id,form.cleaned_data['content']) if success: pbPixel.pixel_type = PIXEL_TYPE_IMAGE pbPixel.content = form.cleaned_data['content'] pbPixel.save() return HttpResponseRedirect(reverse('publisher_kenshoo')) else: inits = { 'advertiser':pbPixel.advertiser.pk, 'pixel_type':pbPixel.pixel_type, 'content':pbPixel.content, } form = KenshooIntegrationEditForm(request.organization, initial=inits) return AQ_render_to_response(request, 'publisher/settings/kenshoo-edit.html', { 'form': form, 'pixel':pbPixel, }, context_instance=RequestContext(request))
def publisher_settings_kenshoo_edit(request, id): ''' View to allow a Publisher to edit a WebSite ''' from forms import KenshooIntegrationEditForm from atrinsic.base.models import Action, Organization pbPixel = get_object_or_404(request.organization.kenshoointegration_set, id=id) if request.method == 'POST': form = KenshooIntegrationEditForm(request.organization, request.POST) advertiserID = request.POST.get("advertiser", None) if form.is_valid(): apeClient = Ape() ape_redirect_id = None getActions = Action.objects.filter( advertiser=Organization.objects.get( id=advertiserID)).order_by('id') if getActions.count() == 0: pass else: ape_redirect_id = getActions[0].ape_redirect_id success, createPixel = apeClient.execute_piggyback_update( request, ape_redirect_id, pbPixel.ape_content_pixel_id, form.cleaned_data['content']) if success: pbPixel.pixel_type = PIXEL_TYPE_IMAGE pbPixel.content = form.cleaned_data['content'] pbPixel.save() return HttpResponseRedirect(reverse('publisher_kenshoo')) else: inits = { 'advertiser': pbPixel.advertiser.pk, 'pixel_type': pbPixel.pixel_type, 'content': pbPixel.content, } form = KenshooIntegrationEditForm(request.organization, initial=inits) return AQ_render_to_response(request, 'publisher/settings/kenshoo-edit.html', { 'form': form, 'pixel': pbPixel, }, context_instance=RequestContext(request))