Example #1
0
def create_campaign(req):
    campaign_url = req.POST["url"]
    
    if not campaign_url.startswith("http://"):
        campaign_url = "http://" + campaign_url

    if req.POST['campaign_type'] == 'raffle':
        template_val = 0
        campaign_url_val = "http://i.bnet.com/blogs/verizon-prepping-the-ipad.jpg"
    elif req.POST['campaign_type'] == 'discount':
        campaign_url_val = campaign_url
        template_val = 2
    else:
        template_val = 0
        campaign_url_val = campaign_url
    

    c = Campaign(
        url=campaign_url,
        url_redeem=campaign_url_val,
        template=template_val
        )

    c.save()
    print "CAMPAIGN CREATE", c.page_views

    c.campaign_type = req.POST['campaign_type']
    c.save()

    c.setHash()
    create_attr(c, name='post', value='')
    create_attr(c, name='follow', value='')
    return HttpResponse(json.dumps({"campaign_hash": c.chash}))