def index(self, *args): self.SetTemplate(templateName='RoleAssociation_lst.html') results =None index = 0; count=1000 try: index = int(self.params.index) count = int(self.params.count) except: pass result = {'RoleAssociationList': RoleAssociation.all().fetch(limit=count, offset=index)} result.update(locals()) self.respond(result)
def edit(self, *args): self.SetTemplate(templateName='RoleAssociation_shw.html') if self.params.key: item = RoleAssociation.get(self.params.key) if item: result = {'op':'upd', 'RoleAssociationForm': RoleAssociationForm(instance=item)} self.respond(result) else: self.status = 'RoleAssociation does not exists' self.redirect(RoleAssociationController.get_url()) else: self.status = 'Key not provided' self.respond({'op':'ins' ,'RoleAssociationForm':RoleAssociationForm()})
def save(self, *args): instance = None if self.params.key: instance = RoleAssociation.get(self.params.key) form=RoleAssociationForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'RoleAssociation is saved' self.redirect(RoleAssociationController.get_url()) else: self.SetTemplate(templateName = 'RoleAssociation_shw.html') self.status = 'Form is not Valid' result = {'op':'upd', 'RoleAssociationForm': form} self.respond(result)
def delete(self, *args): if self.params.key: item = RoleAssociation.get(self.params.key) if item: item.delete() self.status ='RoleAssociation is deleted!' else: self.status='RoleAssociation does not exist' else: self.status = 'Key was not Provided!' self.redirect(RoleAssociationController.get_url()) def index(self, *args): self.SetTemplate(templateName='RoleAssociation_lst.html') results =None index = 0; count=1000 try: index = int(self.params.index) count = int(self.params.count) except: pass result = {'RoleAssociationList': RoleAssociation.all().fetch(limit=count, offset=index)} result.update(locals()) self.respond(result) def save(self, *args): instance = None if self.params.key: instance = RoleAssociation.get(self.params.key) form=RoleAssociationForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'RoleAssociation is saved' self.redirect(RoleAssociationController.get_url()) else: self.SetTemplate(templateName = 'RoleAssociation_shw.html') self.status = 'Form is not Valid' result = {'op':'upd', 'RoleAssociationForm': form} self.respond(result)