Exemple #1
0
def publisher_settings_pixel_add(request):
    ''' View to allow a Publisher the ability to add a WebSite '''
    from atrinsic.base.models import Action, PiggybackPixel
    from forms import PiggybackForm

    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)
            includePixelID = 0
            if form.cleaned_data[
                    'pixel_type'] == PIXEL_TYPE_SCRIPT and form.cleaned_data[
                        'jsinclude'] != "":
                success, createPixel = apeClient.execute_piggyback_create(
                    request, ape_redirect_id, PIXEL_TYPE_IFRAME,
                    form.cleaned_data['jsinclude'])
                if success:
                    includePixelID = createPixel['pixel_id']
            #Call APE and create Piggyback Pixel with redirect determined above.
            success, createPixel = apeClient.execute_piggyback_create(
                request, ape_redirect_id, form.cleaned_data['pixel_type'],
                form.cleaned_data['content'])
            if success:
                PiggybackPixel.objects.create(
                    publisher=request.organization,
                    advertiser=form.cleaned_data['advertiser'],
                    pixel_type=form.cleaned_data['pixel_type'],
                    jsinclude=form.cleaned_data['jsinclude'],
                    ape_content_pixel_id=createPixel['pixel_id'],
                    ape_include_pixel_id=includePixelID,
                    content=form.cleaned_data['content'])

            return HttpResponseRedirect(reverse('publisher_settings_websites'))
    else:
        form = PiggybackForm(request.organization)

    return AQ_render_to_response(request,
                                 'publisher/settings/pixel-add.html', {
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
def publisher_settings_pixel_add(request):
    ''' View to allow a Publisher the ability to add a WebSite '''
    from atrinsic.base.models import Action, PiggybackPixel
    from forms import PiggybackForm
    
    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)
            includePixelID = 0
            if form.cleaned_data['pixel_type'] == PIXEL_TYPE_SCRIPT and form.cleaned_data['jsinclude'] != "":                
                success, createPixel = apeClient.execute_piggyback_create(request,ape_redirect_id,PIXEL_TYPE_IFRAME,form.cleaned_data['jsinclude']) 
                if success:
                    includePixelID = createPixel['pixel_id']
            #Call APE and create Piggyback Pixel with redirect determined above.
            success, createPixel = apeClient.execute_piggyback_create(request,ape_redirect_id,form.cleaned_data['pixel_type'],form.cleaned_data['content'])       
            if success:
                PiggybackPixel.objects.create(publisher=request.organization, advertiser=form.cleaned_data['advertiser'],
                        pixel_type=form.cleaned_data['pixel_type'], jsinclude=form.cleaned_data['jsinclude'], ape_content_pixel_id = createPixel['pixel_id'], ape_include_pixel_id = includePixelID, content=form.cleaned_data['content'])

            return HttpResponseRedirect(reverse('publisher_settings_websites'))
    else:
        form = PiggybackForm(request.organization)

    return AQ_render_to_response(request, 'publisher/settings/pixel-add.html', {
        'form': form,
        }, context_instance=RequestContext(request))
def publisher_settings_kenshoo_add(request):
    ''' View to allow a Publisher the ability to add a WebSite '''
    from atrinsic.base.models import Action, KenshooIntegration
    from forms import KenshooIntegrationAddForm
    
    if request.method == 'POST':
        form = KenshooIntegrationAddForm(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:
                pass
            else:
                ape_redirect_id = getActions[0].ape_redirect_id
            
            kenshooURL = settings.KENSHOO_URL.replace("{{token}}", form.cleaned_data['content'])
            success, createPixel = apeClient.execute_piggyback_create(
                request
                ,ape_redirect_id
                ,PIXEL_TYPE_IMAGE
                ,kenshooURL
            )
            ape_content_id_value = createPixel['pixel_id']
            
            if success :
                KenshooIntegration.objects.create(
                    publisher=request.organization
                    ,advertiser=form.cleaned_data['advertiser']
                    ,pixel_type=PIXEL_TYPE_IMAGE
                    ,ape_content_pixel_id = ape_content_id_value
                    ,content=form.cleaned_data['content']
                )
            
            return HttpResponseRedirect(reverse('publisher_kenshoo'))
    else:
        form = KenshooIntegrationAddForm(request.organization)

    return AQ_render_to_response(request, 'publisher/settings/kenshoo-add.html', {
        'form': form,
        }, context_instance=RequestContext(request))
Exemple #4
0
def publisher_settings_kenshoo_add(request):
    ''' View to allow a Publisher the ability to add a WebSite '''
    from atrinsic.base.models import Action, KenshooIntegration
    from forms import KenshooIntegrationAddForm

    if request.method == 'POST':
        form = KenshooIntegrationAddForm(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:
                pass
            else:
                ape_redirect_id = getActions[0].ape_redirect_id

            kenshooURL = settings.KENSHOO_URL.replace(
                "{{token}}", form.cleaned_data['content'])
            success, createPixel = apeClient.execute_piggyback_create(
                request, ape_redirect_id, PIXEL_TYPE_IMAGE, kenshooURL)
            ape_content_id_value = createPixel['pixel_id']

            if success:
                KenshooIntegration.objects.create(
                    publisher=request.organization,
                    advertiser=form.cleaned_data['advertiser'],
                    pixel_type=PIXEL_TYPE_IMAGE,
                    ape_content_pixel_id=ape_content_id_value,
                    content=form.cleaned_data['content'])

            return HttpResponseRedirect(reverse('publisher_kenshoo'))
    else:
        form = KenshooIntegrationAddForm(request.organization)

    return AQ_render_to_response(request,
                                 'publisher/settings/kenshoo-add.html', {
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))