def index(request): try: tracker_log = TrackerLog.objects.get(date=datetime.today(), tracker__name=request.GET.get("tracker")) except TrackerLog.DoesNotExist: # Check to see if the tracker is valid try: tracker = Tracker.objects.get(name=request.GET.get("tracker")) except Tracker.DoesNotExist: return HttpResponse("Tracker is invalid.") if tracker is not None: tracker_log = TrackerLog(date=datetime.today(), tracker=tracker, sold_total=0) campaign = tracker_log.tracker.campaign campaign.impressions += 1 campaign.save() tracker_log.impressions += 1 tracker_log.save() now = time.localtime(time.time()) lv = LeadView(trackerlog=tracker_log, time=time.strftime("%Y-%m-%d %H:%M:%S", now), url=request.GET.get("url")) lv.save() return HttpResponse()
def index(request): try: tracker_log = TrackerLog.objects.get( date=datetime.today(), tracker__name=request.GET.get('tracker')) except TrackerLog.DoesNotExist: # Check to see if the tracker is valid try: tracker = Tracker.objects.get(name=request.GET.get('tracker')) except Tracker.DoesNotExist: return HttpResponse("Tracker is invalid.") if tracker is not None: tracker_log = TrackerLog(date=datetime.today(), tracker=tracker, sold_total=0) campaign = tracker_log.tracker.campaign campaign.impressions += 1 campaign.save() tracker_log.impressions += 1 tracker_log.save() now = time.localtime(time.time()) lv = LeadView(trackerlog=tracker_log, time=time.strftime("%Y-%m-%d %H:%M:%S", now), url=request.GET.get('url')) lv.save() return HttpResponse()
def new_campaign(request, campaignpk=""): if campaignpk: campaign = Campaign.objects.get(pk=campaignpk) action = '/campaign/tracker/add/'+campaignpk+'/' button = 'Add Tracker' header = 'Add Tracker To Campaign' else: campaign = Campaign(user=request.user, impressions=0, clicks=0, leads_total=0, leads_sold=0) action = '/campaign/new/' button = 'Add Campaign' header = 'Add A New Campaign' design = FormCss() tracker = Tracker() if request.method == 'POST': campaign_form = CampaignForm(data=request.POST, instance=campaign) tracker_form = TrackerForm(data=request.POST, instance=tracker, prefix='t') design_form = DesignForm(data=request.POST, instance=design) if campaign_form.is_valid() and tracker_form.is_valid() and design_form.is_valid(): c = campaign_form.save(commit=False) c.save() d = design_form.save(commit=False) d.save() t = tracker_form.save(commit=False) t.campaign = c t.design = d t.save() tracker_log = TrackerLog(tracker=t) tracker_log.date = datetime.today() tracker_log.sold_total = 0 tracker_log.save() return render_to_response('campaign/new_done.html', {'tracker':t}, context_instance=RequestContext(request)) else: return render_to_response('campaign/new.html', {'campaign_form':campaign_form, 'design_form':design_form, 'tracker_form':tracker_form, 'action': action, 'button':button, 'header':header}, context_instance=RequestContext(request)) else: campaign_form = CampaignForm( instance=campaign) tracker_form = TrackerForm(instance=tracker, prefix='t') design_form = DesignForm(instance=design) return render_to_response('campaign/new.html', {'campaign_form':campaign_form, 'design_form':design_form, 'tracker_form':tracker_form, 'action': action, 'button':button, 'header':header}, context_instance=RequestContext(request))
def new_campaign(request, campaignpk=""): if campaignpk: campaign = Campaign.objects.get(pk=campaignpk) action = '/campaign/tracker/add/' + campaignpk + '/' button = 'Add Tracker' header = 'Add Tracker To Campaign' else: campaign = Campaign(user=request.user, impressions=0, clicks=0, leads_total=0, leads_sold=0) action = '/campaign/new/' button = 'Add Campaign' header = 'Add A New Campaign' design = FormCss() tracker = Tracker() if request.method == 'POST': campaign_form = CampaignForm(data=request.POST, instance=campaign) tracker_form = TrackerForm(data=request.POST, instance=tracker, prefix='t') design_form = DesignForm(data=request.POST, instance=design) if campaign_form.is_valid() and tracker_form.is_valid( ) and design_form.is_valid(): c = campaign_form.save(commit=False) c.save() d = design_form.save(commit=False) d.save() t = tracker_form.save(commit=False) t.campaign = c t.design = d t.save() tracker_log = TrackerLog(tracker=t) tracker_log.date = datetime.today() tracker_log.sold_total = 0 tracker_log.save() return render_to_response('campaign/new_done.html', {'tracker': t}, context_instance=RequestContext(request)) else: return render_to_response('campaign/new.html', { 'campaign_form': campaign_form, 'design_form': design_form, 'tracker_form': tracker_form, 'action': action, 'button': button, 'header': header }, context_instance=RequestContext(request)) else: campaign_form = CampaignForm(instance=campaign) tracker_form = TrackerForm(instance=tracker, prefix='t') design_form = DesignForm(instance=design) return render_to_response('campaign/new.html', { 'campaign_form': campaign_form, 'design_form': design_form, 'tracker_form': tracker_form, 'action': action, 'button': button, 'header': header }, context_instance=RequestContext(request))