def details(self, *args): if self.params.key: item = Grouper.get(self.params.key) if item: return {'op':'update', 'GrouperForm': GrouperForm(instance=item)} else: self.status = 'Grouper does not exists' self.redirect(GrouperController.get_url()) else: self.status = 'Key not provided' return {'op':'insert' ,'GrouperForm':GrouperForm()}
def delete(self,*args): if self.params.key: item = Grouper.get(self.params.key) if item: item.delete() self.status ='Grouper is deleted!' else: self.status='Grouper does not exist' else: self.status = 'Key was not Provided!' self.redirect(GrouperController.get_url())
def delete(self, *args): if self.params.key: item = Grouper.get(self.params.key) if item: item.delete() self.status = 'Grouper is deleted!' else: self.status = 'Grouper does not exist' else: self.status = 'Key was not Provided!' self.redirect(GrouperController.get_url())
def index(self, *args): self.SetTemplate(templateName="Grouper_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 = {'GrouperList': Grouper.all().fetch(limit=count, offset=index)} result.update(locals()) return result
def save(self, *args): instance = None if self.params.key: instance = Grouper.get(self.params.key) form=GrouperForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'Grouper is saved' self.redirect(GrouperController.get_url()) else: self.SetTemplate(templateName = 'Grouper_edit.html') self.status = 'Form is not Valid' return {'op':'upd', 'GrouperForm': form}
def details(self, *args): if self.params.key: item = Grouper.get(self.params.key) if item: return { 'op': 'update', 'GrouperForm': GrouperForm(instance=item) } else: self.status = 'Grouper does not exists' self.redirect(GrouperController.get_url()) else: self.status = 'Key not provided' return {'op': 'insert', 'GrouperForm': GrouperForm()}
def save(self, *args): instance = None if self.params.key: instance = Grouper.get(self.params.key) form = GrouperForm(data=self.request.POST, instance=instance) if form.is_valid(): result = form.save(commit=False) result.put() self.status = 'Grouper is saved' self.redirect(GrouperController.get_url()) else: self.SetTemplate(templateName='Grouper_edit.html') self.status = 'Form is not Valid' return {'op': 'upd', 'GrouperForm': form}
def index(self, *args): self.SetTemplate(templateName="Grouper_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 = { 'GrouperList': Grouper.all().fetch(limit=count, offset=index) } result.update(locals()) return result