def details(self, *args): if self.params.key: item = Promotion.get(self.params.key) if item: return {'op':'update', 'PromotionForm': PromotionForm(instance=item)} else: self.status = 'Promotion does not exists' self.redirect(PromotionController.get_url()) else: self.status = 'Key not provided' return {'op':'insert' ,'PromotionForm':PromotionForm()}
def delete(self,*args): if self.params.key: item = Promotion.get(self.params.key) if item: item.delete() self.status ='Promotion is deleted!' else: self.status='Promotion does not exist' else: self.status = 'Key was not Provided!' self.redirect(PromotionController.get_url())
def delete(self, *args): if self.params.key: item = Promotion.get(self.params.key) if item: item.delete() self.status = 'Promotion is deleted!' else: self.status = 'Promotion does not exist' else: self.status = 'Key was not Provided!' self.redirect(PromotionController.get_url())
def index(self, *args): self.SetTemplate(templateName="Promotion_index.html") results =None index = 0; count=20 try: index = int(self.params.index) count = int(self.params.count) except: pass nextIndex = index+count; previousIndex = index<=0 and -1 or (index-count>0 and 0 or index-count) result = {'PromotionList': Promotion.all().fetch(limit=count, offset=index)} result.update(locals()) return result
def save(self, *args): instance = None if self.params.key: instance = Promotion.get(self.params.key) form=PromotionForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'Promotion is saved' self.redirect(PromotionController.get_url()) else: self.SetTemplate(templateName = 'Promotion_edit.html') self.status = 'Form is not Valid' return {'op':'update', 'PromotionForm': form}
def details(self, *args): if self.params.key: item = Promotion.get(self.params.key) if item: return { 'op': 'update', 'PromotionForm': PromotionForm(instance=item) } else: self.status = 'Promotion does not exists' self.redirect(PromotionController.get_url()) else: self.status = 'Key not provided' return {'op': 'insert', 'PromotionForm': PromotionForm()}
def save(self, *args): instance = None if self.params.key: instance = Promotion.get(self.params.key) form = PromotionForm(data=self.request.POST, instance=instance) if form.is_valid(): result = form.save(commit=False) result.put() self.status = 'Promotion is saved' self.redirect(PromotionController.get_url()) else: self.SetTemplate(templateName='Promotion_edit.html') self.status = 'Form is not Valid' return {'op': 'update', 'PromotionForm': form}
def index(self, *args): self.SetTemplate(templateName="Promotion_index.html") results = None index = 0 count = 20 try: index = int(self.params.index) count = int(self.params.count) except: pass nextIndex = index + count previousIndex = index <= 0 and -1 or (index - count > 0 and 0 or index - count) result = { 'PromotionList': Promotion.all().fetch(limit=count, offset=index) } result.update(locals()) return result