def create_campaign(request): response = reply_object() try: c = Campaign() new_campaign_id = c.start_campaign(request.user.id).id response["code"] = settings.APP_CODE["CALLBACK"] response["campaign_id"] = new_campaign_id.__str__() except: response["code"] = settings.APP_CODE["SYSTEM ERROR"] return HttpResponse(simplejson.dumps(response))
def list_campaigns(request, page): response = reply_object() try: per_page = 20 pages = paginate(page, per_page) camp_obj = Campaign() paginator = pagination_string(camp_obj.count(request.user.id), int(page), per_page, "#/list/adv/") campaigns = camp_obj.my_campaigns(request.user.id, pages["from"], pages["to"]) page = render_to_string("campaigns.html", {"campaigns" : campaigns, "paginator" : paginator}) response["code"] = settings.APP_CODE["PAGE LOADED"] response["page"] = page except: response["code"] = settings.APP_CODE["SYSTEM ERROR"] return HttpResponse(simplejson.dumps(response))