예제 #1
0
def publisher_settings_pixel_delete(request, id):
    ''' View to allow a Publisher to delete a WebSite '''
    from atrinsic.base.models import Action

    pbPixel = get_object_or_404(request.organization.piggybackpixel_set, id=id)

    apeClient = Ape()
    ape_redirect_id = None
    getActions = Action.objects.filter(
        advertiser=pbPixel.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 pbPixel.ape_content_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(
            request, ape_redirect_id, pbPixel.ape_content_pixel_id)

    if pbPixel.ape_include_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(
            request, ape_redirect_id, pbPixel.ape_include_pixel_id)

    #pbPixel.delete()
    return HttpResponseRedirect(reverse('publisher_piggyback_pixel'))
예제 #2
0
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))
예제 #3
0
def publisher_settings_pixel_delete(request, id):
    ''' View to allow a Publisher to delete a WebSite '''    
    from atrinsic.base.models import Action
    
    pbPixel = get_object_or_404(request.organization.piggybackpixel_set, id=id)
    
    apeClient = Ape()            
    ape_redirect_id = None   
    getActions = Action.objects.filter(advertiser=pbPixel.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 pbPixel.ape_content_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(request,ape_redirect_id,pbPixel.ape_content_pixel_id)
         
    if pbPixel.ape_include_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(request,ape_redirect_id,pbPixel.ape_include_pixel_id)       
                         
    #pbPixel.delete()
    return HttpResponseRedirect(reverse('publisher_piggyback_pixel'))
예제 #4
0
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))
예제 #5
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))
예제 #6
0
def network_advertiser_tracking_add(request, id):
    ''' View to allow a Network Admin to create new Tracking Actions for an Advertiser '''
    from atrinsic.base.models import Action
    from forms import NetworkActionForm
    advertiser = get_object_or_404(
        request.user.get_profile().admin_assigned_advertisers(), id=id)
    if request.method == 'POST':
        form = NetworkActionForm(request.POST)
        if form.is_valid():
            apeClient = Ape()
            ape_redirect_id = None
            ape_action_id = None

            getActions = Action.objects.filter(
                advertiser=advertiser).order_by('id')
            if getActions.count() == 0:
                #Call APE to create new REDIRECT
                success, createPixel = apeClient.execute_redirect_create()
                if success:
                    ape_redirect_id = createPixel['redirect_id']

            else:
                #Use RedirectID from Oldest Action(order_by('id')) and create actions under that RedirectID
                ape_redirect_id = getActions[0].ape_redirect_id

            #Call APE and create Action with redirect determined above.
            success, createAction = apeClient.execute_action_create(
                ape_redirect_id, form.cleaned_data['name'])
            if success:
                print "createAction - %s" % createAction
                ape_action_id = createAction['action_id']

            a = Action.objects.create(
                advertiser=advertiser,
                name=form.cleaned_data['name'],
                status=form.cleaned_data['status'],
                network_fee=0,
                ape_redirect_id=ape_redirect_id,
                ape_action_id=ape_action_id,
                advertiser_payout_type=str(
                    form.cleaned_data['advertiser_payout_type']),
                advertiser_payout_amount=str(
                    form.cleaned_data['advertiser_payout_amount']))

            return HttpResponseRedirect('/network/advertiser/tracking/%d/' %
                                        advertiser.id)
    else:
        form = NetworkActionForm()

    return AQ_render_to_response(request,
                                 'network/tracking-add.html', {
                                     'advertiser': advertiser,
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
예제 #7
0
def network_advertiser_tracking_edit(request, advertiser_id, action_id):
    ''' View to allow a Network Admin to edit the tracking actions of an Advertiser '''

    advertiser = get_object_or_404(request.user.get_profile().admin_assigned_advertisers(), id=advertiser_id)
    action = get_object_or_404(advertiser.action_set, id=action_id)
    apeRedirect = 0
    securePixel = ""
    nonSecurePixel = ""
    if request.method == 'POST':
        form = NetworkActionForm(request.POST)

        if form.is_valid():
            
            if action.ape_redirect_id == None or action.ape_redirect_id == 0:
                apeClient = Ape()
                success, createPixel = apeClient.execute_redirect_create()
                if success:
                    action.ape_redirect_id = createPixel['redirect_id']
            
            action.status = form.cleaned_data['status']
            action.name = form.cleaned_data['name']
            if form.cleaned_data['invite_id']:
                action.invite_id = form.cleaned_data['invite_id']
                
            action.network_fee = 0
            action.advertiser_payout_type=str(form.cleaned_data['advertiser_payout_type'])
            action.advertiser_payout_amount=str(form.cleaned_data['advertiser_payout_amount'])
            action.save()            
            return HttpResponseRedirect('/network/advertiser/tracking/%d/' % advertiser.id)
    else:
        if action.ape_redirect_id > 0:
            apeRedirect = base36_encode(action.ape_redirect_id)            
            securePixel = settings.APE_SECURE_PIXEL_URL + str(apeRedirect)
            nonSecurePixel = settings.APE_PIXEL_URL + str(apeRedirect)
            if action.ape_action_id != None:
                apeAction = base36_encode(action.ape_action_id)      
                securePixel = '%s/%s/' % (securePixel, apeAction)
                nonSecurePixel = '%s/%s/' % (nonSecurePixel, apeAction)
                
        else:
            apeRedirect = 0
        form = NetworkActionForm(initial={ 'name' : action.name, 'status' : action.status,
                                           'advertiser_payout_type' : action.advertiser_payout_type,
                                           'advertiser_payout_amount' : action.advertiser_payout_amount,
                                           'invite_id' : action.invite_id })

    
    return AQ_render_to_response(request, 'network/tracking-edit.html', {
            'advertiser' : advertiser,
            'action' : action,
            'form' : form,
            'apeRedirect' : apeRedirect,
            'securePixel' : securePixel,
            'nonSecurePixel' : nonSecurePixel,
        }, context_instance=RequestContext(request))
예제 #8
0
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))
예제 #9
0
def publisher_links_build(request):
    from atrinsic.base.models import Link,ProgramTerm,ProgramTermAction,Organization
    from forms import adbuilderForm
    from atrinsic.util.ApeApi import Ape
    from atrinsic.util.links.CustomLinks import CustomLinks
    
    try:
        adv = Organization.objects.get(id=request.POST['advertisers'])
        cl = CustomLinks()
        
        if request.POST['linkId'] == "0":
            l = Link(link_type=LINKTYPE_TEXT)
        else:
            l = Link.objects.get(id=request.POST['linkId'])	    
        
        l.byo = True
        l.advertiser = adv
        l.publisher = request.organization
        l.name = request.POST['name']
        l.landing_page_url = request.POST['destination']
        l.landing_page = request.POST['destination']
        l.link_content = request.POST['content']
        
        pt = ProgramTerm.objects.get(advertiser=adv,is_default=True)
        ptAction = ProgramTermAction.objects.select_related("action").get(program_term=pt)
        apeClient = Ape()
        
        #Create custom landing page if needed
        lp = cl.generate_link(adv.name,l)
        if lp != "":
            l.landing_page_url = lp
        
        #Create APE tracking
        if request.POST['linkId'] == "0":
            apeClient.execute_url_create(ptAction.action, l)            
        else:
            apeClient.execute_url_update(ptAction, l)
        
        l.save()
        link_id = l.id
        
        result = "Your link was created successfully"
    except:
        result = "A problem accoured while creating your link. Please contact your system administrator"
        
    return HttpResponse(str(link_id), mimetype="text/html")
    
    
    '''
예제 #10
0
def network_account_advertiser_requests_approve(request, id):
    ''' View to approve an Advertiser DataFeed Request '''
    from atrinsic.base.models import DataFeed, ProgramTermAction, ProgramTerm
    
    d = get_object_or_404(DataFeed, id=id)
    # Get default Program Term, Action so we can get the Adv.'s redirect_id
    pt = ProgramTerm.objects.get(advertiser=d.advertiser,is_default=True)
    ptAction = ProgramTermAction.objects.select_related("action").get(program_term=pt)
    
    print ptAction.action.name
    apeClient = Ape()
    d.ape_url_id = apeClient.execute_url_create(ptAction.action, None, d)
    d.status = STATUS_LIVE
    d.save()

    return HttpResponseRedirect('/network/account/advertiser/requests/')
예제 #11
0
def network_advertiser_datafeed_add(request, id):
    ''' View to create an Advertiser DataFeed '''
    from atrinsic.base.models import DataFeed, ProgramTerm, ProgramTermAction
    from forms import NetworkDataFeedForm

    advertiser = get_object_or_404(
        request.user.get_profile().admin_assigned_advertisers(), id=id)

    if request.method == 'POST':
        form = NetworkDataFeedForm(request.POST)

        if form.is_valid():

            df = DataFeed.objects.create(
                advertiser=advertiser,
                name=form.cleaned_data['name'],
                landing_page_url=form.cleaned_data['landing_page_url'],
                status=form.cleaned_data['status'],
                datafeed_type=form.cleaned_data['datafeed_type'],
                datafeed_format=form.cleaned_data['datafeed_format'],
                username=form.cleaned_data['username'],
                password=form.cleaned_data['password'],
                server=form.cleaned_data['server'])

            try:
                pt = ProgramTerm.objects.get(advertiser=advertiser,
                                             is_default=True)
                ptAction = ProgramTermAction.objects.select_related(
                    "action").get(program_term=pt)

                apeClient = Ape()
                df.ape_url_id = apeClient.execute_url_create(
                    ptAction.action, None, df)
                df.save()
            except:
                pass
            return HttpResponseRedirect('/network/advertiser/datafeed/%d/' %
                                        advertiser.id)
    else:
        form = NetworkDataFeedForm()

    return AQ_render_to_response(request,
                                 'network/datafeed-add.html', {
                                     'advertiser': advertiser,
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
예제 #12
0
def network_account_advertiser_requests_approve(request, id):
    ''' View to approve an Advertiser DataFeed Request '''
    from atrinsic.base.models import DataFeed, ProgramTermAction, ProgramTerm

    d = get_object_or_404(DataFeed, id=id)
    # Get default Program Term, Action so we can get the Adv.'s redirect_id
    pt = ProgramTerm.objects.get(advertiser=d.advertiser, is_default=True)
    ptAction = ProgramTermAction.objects.select_related("action").get(
        program_term=pt)

    print ptAction.action.name
    apeClient = Ape()
    d.ape_url_id = apeClient.execute_url_create(ptAction.action, None, d)
    d.status = STATUS_LIVE
    d.save()

    return HttpResponseRedirect('/network/account/advertiser/requests/')
예제 #13
0
def network_advertiser_tracking_add(request, id):
    ''' View to allow a Network Admin to create new Tracking Actions for an Advertiser '''
    from atrinsic.base.models import Action
    from forms import NetworkActionForm
    advertiser = get_object_or_404(request.user.get_profile().admin_assigned_advertisers(), id=id)
    if request.method == 'POST':
        form = NetworkActionForm(request.POST)
        if form.is_valid():                
            apeClient = Ape()
            ape_redirect_id = None   
            ape_action_id = None 

            getActions = Action.objects.filter(advertiser=advertiser).order_by('id')
            if getActions.count() == 0:
                #Call APE to create new REDIRECT
                success, createPixel = apeClient.execute_redirect_create()            
                if success:
                    ape_redirect_id = createPixel['redirect_id']

            else:
                #Use RedirectID from Oldest Action(order_by('id')) and create actions under that RedirectID
                ape_redirect_id = getActions[0].ape_redirect_id
            
                
            #Call APE and create Action with redirect determined above.
            success, createAction = apeClient.execute_action_create(ape_redirect_id,form.cleaned_data['name'])       
            if success:
                print "createAction - %s" % createAction
                ape_action_id = createAction['action_id']      
            
            a = Action.objects.create(advertiser=advertiser, name=form.cleaned_data['name'],
                                      status=form.cleaned_data['status'], network_fee=0,
                                      ape_redirect_id=ape_redirect_id,
                                      ape_action_id=ape_action_id,
                                      advertiser_payout_type=str(form.cleaned_data['advertiser_payout_type']),
                                      advertiser_payout_amount=str(form.cleaned_data['advertiser_payout_amount']))
            
            return HttpResponseRedirect('/network/advertiser/tracking/%d/' % advertiser.id)
    else:
        form = NetworkActionForm()

    return AQ_render_to_response(request, 'network/tracking-add.html', {
            'advertiser' : advertiser,
            'form' : form,
        }, context_instance=RequestContext(request))
예제 #14
0
def network_advertiser_datafeed_edit(request, advertiser_id, datafeed_id):
    ''' View to allow a Network Admin to edit the DataFeed of an Advertiser '''
    from atrinsic.base.models import ProgramTermAction, ProgramTerm
    from forms import NetworkDataFeedForm

    advertiser = get_object_or_404(
        request.user.get_profile().admin_assigned_advertisers(),
        id=advertiser_id)
    datafeed = get_object_or_404(advertiser.datafeed_set, id=datafeed_id)

    if request.method == 'POST':
        form = NetworkDataFeedForm(request.POST)

        if form.is_valid():
            datafeed.status = form.cleaned_data['status']
            datafeed.name = form.cleaned_data['name']
            datafeed.landing_page_url = form.cleaned_data['landing_page_url']
            datafeed.datafeed_type = form.cleaned_data['datafeed_type']
            datafeed.datafeed_format = form.cleaned_data['datafeed_format']
            datafeed.username = form.cleaned_data['username']
            datafeed.password = form.cleaned_data['password']
            datafeed.server = form.cleaned_data['server']
            datafeed.save()

            pt = ProgramTerm.objects.get(advertiser=advertiser,
                                         is_default=True)
            ptAction = ProgramTermAction.objects.select_related("action").get(
                program_term=pt)
            apeClient = Ape()

            if datafeed.ape_url_id == 0 or datafeed.ape_url_id == None:
                datafeed.ape_url_id = apeClient.execute_url_create(
                    ptAction.action, None, datafeed)
                datafeed.save()
            else:
                apeClient.execute_url_update(ptAction.action, None, datafeed)

            apeClient.execute_url_update(ptAction.action, None, datafeed)
            return HttpResponseRedirect('/network/advertiser/datafeed/%d/' %
                                        advertiser.id)
    else:
        form = NetworkDataFeedForm(
            initial={
                'name': datafeed.name,
                'landing_page_url': datafeed.landing_page_url,
                'status': datafeed.status,
                'datafeed_type': datafeed.datafeed_type,
                'datafeed_format': datafeed.datafeed_format,
                'username': datafeed.username,
                'password': datafeed.password,
                'server': datafeed.server,
            })

    return AQ_render_to_response(request,
                                 'network/datafeed-edit.html', {
                                     'advertiser': advertiser,
                                     'datafeed': datafeed,
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
예제 #15
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))
예제 #16
0
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))
예제 #17
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))
예제 #18
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))
예제 #19
0
def publisher_settings_kenshoo_delete(request, id):
    from atrinsic.base.models import Action, KenshooIntegration
    try:
        pbPixel = KenshooIntegration.objects.get(id=id)
    except:
        return HttpResponseRedirect(reverse('publisher_kenshoo'))
    
    apeClient = Ape()            
    ape_redirect_id = None   
    getActions = Action.objects.filter(advertiser=pbPixel.advertiser).order_by('id')
    if getActions.count() == 0:
        pass
    else:
        ape_redirect_id = getActions[0].ape_redirect_id
    if pbPixel.ape_content_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(request,ape_redirect_id,pbPixel.ape_content_pixel_id)       
    if success:
        try:
            pbPixel.delete()
        except:
            pass
    return HttpResponseRedirect(reverse('publisher_kenshoo'))
예제 #20
0
def network_advertiser_datafeed_add(request, id):
    ''' View to create an Advertiser DataFeed '''
    from atrinsic.base.models import DataFeed, ProgramTerm, ProgramTermAction
    from forms import NetworkDataFeedForm
    
    advertiser = get_object_or_404(request.user.get_profile().admin_assigned_advertisers(), id=id)

    if request.method == 'POST':
        form = NetworkDataFeedForm(request.POST)

        if form.is_valid():            
                
            
            df = DataFeed.objects.create(advertiser=advertiser, name=form.cleaned_data['name'],
                    landing_page_url=form.cleaned_data['landing_page_url'],status=form.cleaned_data['status'], 
                    datafeed_type=form.cleaned_data['datafeed_type'],datafeed_format=form.cleaned_data['datafeed_format'], 
                    username=form.cleaned_data['username'],password=form.cleaned_data['password'], 
                    server=form.cleaned_data['server'])
                    
            try:
                pt = ProgramTerm.objects.get(advertiser=advertiser,is_default=True)
                ptAction = ProgramTermAction.objects.select_related("action").get(program_term=pt)
                
                apeClient = Ape()
                df.ape_url_id = apeClient.execute_url_create(ptAction.action, None, df)
                df.save()
            except:
                pass
            return HttpResponseRedirect('/network/advertiser/datafeed/%d/' % advertiser.id)
    else:
        form = NetworkDataFeedForm()

    return AQ_render_to_response(request, 'network/datafeed-add.html', {
            'advertiser' : advertiser,
            'form' : form,
        }, context_instance=RequestContext(request))
예제 #21
0
def publisher_settings_kenshoo_delete(request, id):
    from atrinsic.base.models import Action, KenshooIntegration
    try:
        pbPixel = KenshooIntegration.objects.get(id=id)
    except:
        return HttpResponseRedirect(reverse('publisher_kenshoo'))

    apeClient = Ape()
    ape_redirect_id = None
    getActions = Action.objects.filter(
        advertiser=pbPixel.advertiser).order_by('id')
    if getActions.count() == 0:
        pass
    else:
        ape_redirect_id = getActions[0].ape_redirect_id
    if pbPixel.ape_content_pixel_id != 0:
        success, createPixel = apeClient.execute_piggyback_delete(
            request, ape_redirect_id, pbPixel.ape_content_pixel_id)
    if success:
        try:
            pbPixel.delete()
        except:
            pass
    return HttpResponseRedirect(reverse('publisher_kenshoo'))
예제 #22
0
def network_advertiser_datafeed_edit(request, advertiser_id, datafeed_id):
    ''' View to allow a Network Admin to edit the DataFeed of an Advertiser '''    
    from atrinsic.base.models import ProgramTermAction, ProgramTerm
    from forms import NetworkDataFeedForm
    
    advertiser = get_object_or_404(request.user.get_profile().admin_assigned_advertisers(), id=advertiser_id)
    datafeed = get_object_or_404(advertiser.datafeed_set, id=datafeed_id)

    if request.method == 'POST':
        form = NetworkDataFeedForm(request.POST)

        if form.is_valid():
            datafeed.status = form.cleaned_data['status']
            datafeed.name = form.cleaned_data['name']
            datafeed.landing_page_url = form.cleaned_data['landing_page_url']
            datafeed.datafeed_type = form.cleaned_data['datafeed_type']
            datafeed.datafeed_format = form.cleaned_data['datafeed_format']
            datafeed.username = form.cleaned_data['username']
            datafeed.password = form.cleaned_data['password']
            datafeed.server = form.cleaned_data['server']
            datafeed.save()
            
            pt = ProgramTerm.objects.get(advertiser=advertiser,is_default=True)
            ptAction = ProgramTermAction.objects.select_related("action").get(program_term=pt)
            apeClient = Ape()      
            
            if datafeed.ape_url_id == 0 or datafeed.ape_url_id == None:
                datafeed.ape_url_id = apeClient.execute_url_create(ptAction.action, None, datafeed)  
                datafeed.save()
            else:     
                apeClient.execute_url_update(ptAction.action, None, datafeed)
            
                  
            apeClient.execute_url_update(ptAction.action, None, datafeed)
            return HttpResponseRedirect('/network/advertiser/datafeed/%d/' % advertiser.id)
    else:
        form = NetworkDataFeedForm(initial={ 'name' : datafeed.name, 'landing_page_url' : datafeed.landing_page_url, 
                                             'status' : datafeed.status,'datafeed_type' : datafeed.datafeed_type, 
                                             'datafeed_format' : datafeed.datafeed_format,
                                             'username' : datafeed.username, 'password' : datafeed.password,
                                             'server' : datafeed.server, })

    
    return AQ_render_to_response(request, 'network/datafeed-edit.html', {
            'advertiser' : advertiser,
            'datafeed' : datafeed,
            'form' : form,
        }, context_instance=RequestContext(request))
예제 #23
0
def publisher_links_build(request):
    from atrinsic.base.models import Link, ProgramTerm, ProgramTermAction, Organization
    from forms import adbuilderForm
    from atrinsic.util.ApeApi import Ape
    from atrinsic.util.links.CustomLinks import CustomLinks

    try:
        adv = Organization.objects.get(id=request.POST['advertisers'])
        cl = CustomLinks()

        if request.POST['linkId'] == "0":
            l = Link(link_type=LINKTYPE_TEXT)
        else:
            l = Link.objects.get(id=request.POST['linkId'])

        l.byo = True
        l.advertiser = adv
        l.publisher = request.organization
        l.name = request.POST['name']
        l.landing_page_url = request.POST['destination']
        l.landing_page = request.POST['destination']
        l.link_content = request.POST['content']

        pt = ProgramTerm.objects.get(advertiser=adv, is_default=True)
        ptAction = ProgramTermAction.objects.select_related("action").get(
            program_term=pt)
        apeClient = Ape()

        #Create custom landing page if needed
        lp = cl.generate_link(adv.name, l)
        if lp != "":
            l.landing_page_url = lp

        #Create APE tracking
        if request.POST['linkId'] == "0":
            apeClient.execute_url_create(ptAction.action, l)
        else:
            apeClient.execute_url_update(ptAction, l)

        l.save()
        link_id = l.id

        result = "Your link was created successfully"
    except:
        result = "A problem accoured while creating your link. Please contact your system administrator"

    return HttpResponse(str(link_id), mimetype="text/html")
    '''
예제 #24
0
def network_advertiser_tracking_edit(request, advertiser_id, action_id):
    ''' View to allow a Network Admin to edit the tracking actions of an Advertiser '''

    advertiser = get_object_or_404(
        request.user.get_profile().admin_assigned_advertisers(),
        id=advertiser_id)
    action = get_object_or_404(advertiser.action_set, id=action_id)
    apeRedirect = 0
    securePixel = ""
    nonSecurePixel = ""
    if request.method == 'POST':
        form = NetworkActionForm(request.POST)

        if form.is_valid():

            if action.ape_redirect_id == None or action.ape_redirect_id == 0:
                apeClient = Ape()
                success, createPixel = apeClient.execute_redirect_create()
                if success:
                    action.ape_redirect_id = createPixel['redirect_id']

            action.status = form.cleaned_data['status']
            action.name = form.cleaned_data['name']
            if form.cleaned_data['invite_id']:
                action.invite_id = form.cleaned_data['invite_id']

            action.network_fee = 0
            action.advertiser_payout_type = str(
                form.cleaned_data['advertiser_payout_type'])
            action.advertiser_payout_amount = str(
                form.cleaned_data['advertiser_payout_amount'])
            action.save()
            return HttpResponseRedirect('/network/advertiser/tracking/%d/' %
                                        advertiser.id)
    else:
        if action.ape_redirect_id > 0:
            apeRedirect = base36_encode(action.ape_redirect_id)
            securePixel = settings.APE_SECURE_PIXEL_URL + str(apeRedirect)
            nonSecurePixel = settings.APE_PIXEL_URL + str(apeRedirect)
            if action.ape_action_id != None:
                apeAction = base36_encode(action.ape_action_id)
                securePixel = '%s/%s/' % (securePixel, apeAction)
                nonSecurePixel = '%s/%s/' % (nonSecurePixel, apeAction)

        else:
            apeRedirect = 0
        form = NetworkActionForm(
            initial={
                'name': action.name,
                'status': action.status,
                'advertiser_payout_type': action.advertiser_payout_type,
                'advertiser_payout_amount': action.advertiser_payout_amount,
                'invite_id': action.invite_id
            })

    return AQ_render_to_response(request,
                                 'network/tracking-edit.html', {
                                     'advertiser': advertiser,
                                     'action': action,
                                     'form': form,
                                     'apeRedirect': apeRedirect,
                                     'securePixel': securePixel,
                                     'nonSecurePixel': nonSecurePixel,
                                 },
                                 context_instance=RequestContext(request))