Exemple #1
0
def get_adv_parameters(request, page, campaign):
    per_page = 20
    pages = paginate(page, per_page)
    paginator = ajax_pagination_string(len(campaign.ads),
                                  int(page),per_page,
                                  "App.Ad.get_adv_page")
    advs = Ad.objects(id__in=campaign.ads)[pages["from"]:pages["to"]]
    params = {"advs" : advs, "adv_paginator" : paginator}
    return params
Exemple #2
0
 def save_ad(self):  
     response = reply_object()
     ad = Ad(title = self.cleaned_data["title"],
             description_line1 = self.cleaned_data["description_line1"],
             description_line2 = self.cleaned_data["description_line2"],
             display_url = self.cleaned_data["display_url"],
             url = self.cleaned_data["url"],
             ad_category = self.cleaned_data["ad_category"],
             user = self.request.user.id)
     ad.save()
     campaign = Campaign.objects.get\
         (id=self.cleaned_data["related_object_id"],
          user=self.request.user.id)
     campaign.ads.append(ad.id.__str__())
     campaign.save()
     response["code"] = settings.APP_CODE["SAVED"]
     response["ad_object_id"] = ad.id.__str__()
     return response
Exemple #3
0
def edit_adv(request, object_id):
    response = reply_object()
    #try:
    if True:
        ad_obj = Ad()
        ad = ad_obj.get_my_ad(object_id, request.user.id)
        response["form_dict"] = {}
        values = {"ad_object_id" : ad.id.__str__(),
                  "title" : ad.title,
                  "description_line1" : ad.description_line1,
                  "description_line2" : ad.description_line2,
                  "display_url" : ad.display_url,
                  "url" : ad.url,
                  "ad_category" : ad.ad_category}
        response["form_dict"]["values"] = values
        response["code"] = settings.APP_CODE["FORM LOADED"]
    #except:
    #    response["code"] = settings.APP_CODE["SYSTEM ERROR"]

    return HttpResponse(simplejson.dumps(response))