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