def post(self,campaign_id): user = users.get_current_user() if not user: return self.redirect(users.create_login_url(self.request.uri)) name = self.request.get('name',None) target_url = self.request.get('target_url',None) priority = self.request.get('priority',None) img = self.request.POST['img'] alt_text = self.request.get('alt_text',None) title_text = self.request.get('title_text',None) if not target_url or not img.value: return self.get(campaign_id,['Faltan campos obligatorios',]) campaign = Campaign.get_by_id(int(campaign_id)) ad = ImgAdvert( name = name, target_url=target_url, priority=int(priority), img=img.value, mimetype=img.type, alt_text = alt_text, title_text = title_text, campaign = campaign) ad.put() if ad.is_saved(): return self.redirect(webapp2.uri_for('advert.view',advert_id=ad.key().id())) self.response.set_status(500)
def get(self,img_advert_id): ad = ImgAdvert.get_by_id(int(img_advert_id)) if ad.img: self.response.headers['Content-Type'] = ad.mimetype self.response.out.write(ad.img) else: self.response.out.write("No image")
def get(self, img_advert_id): ad = ImgAdvert.get_by_id(int(img_advert_id)) if ad.img: self.response.headers['Content-Type'] = ad.mimetype self.response.out.write(ad.img) else: self.response.out.write("No image")
def post(self, campaign_id): user = users.get_current_user() if not user: return self.redirect(users.create_login_url(self.request.uri)) name = self.request.get('name', None) target_url = self.request.get('target_url', None) priority = self.request.get('priority', None) img = self.request.POST['img'] alt_text = self.request.get('alt_text', None) title_text = self.request.get('title_text', None) if not target_url or not img.value: return self.get(campaign_id, [ 'Faltan campos obligatorios', ]) campaign = Campaign.get_by_id(int(campaign_id)) ad = ImgAdvert(name=name, target_url=target_url, priority=int(priority), img=img.value, mimetype=img.type, alt_text=alt_text, title_text=title_text, campaign=campaign) ad.put() if ad.is_saved(): return self.redirect( webapp2.uri_for('advert.view', advert_id=ad.key().id())) self.response.set_status(500)