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