def delete(self,*args): if self.params.key: item = Branch.get(self.params.key) if item: item.delete() self.status ='Branch is deleted!' else: self.status='Branch does not exist' else: self.status = 'Key was not Provided!' self.redirect(BranchController.get_url())
def details(self, *args): if self.params.key: item = Branch.get(self.params.key) if item: return {'op':'update', 'BranchForm': BranchForm(instance=item)} else: self.status = 'Branch does not exists' self.redirect(BranchController.get_url()) else: self.status = 'Key not provided' return {'op':'insert' ,'BranchForm':BranchForm()}
def save(self, *args): instance = None if self.params.key: instance = Branch.get(self.params.key) form=BranchForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'Branch is saved' self.redirect(BranchController.get_url()) else: self.SetTemplate(templateName = 'Branch_edit.html') self.status = 'Form is not Valid' return {'op':'update', 'BranchForm': form}