def POST(self, post_id=None, action='add'): self.init_data(post_id, 'update') #switch to "update" and lose "edit" state form = self.form_class() if form.validates(): active = True if form.get('active').value else False title = form.get('title').value body = form.get('body').value if action == 'edit': post_data = self.post post_data.title=title post_data.body=body else: post_data = Post(title=title, body=body,) post_data.active=active post_data.put() return web.seeother('/post/'+post_data.slug+'-'+str(post_data.key().id()), absolute=True) context['form'] = form return render_template('add.html', **context)
def POST(self, name, action='view'): self.init_data(name, action) form = self.form_class() if form.validates(): active = True if form.get('active').value else False if not self.content: static_data = Static(position=int(form.get('position').value), name=form.get('name').value.lstrip('/'), label=form.get('label').value, title=form.get('title').value, content=form.get('content').value, active=active,) else: self.content.position=int(form.get('position').value) self.content.name=form.get('name').value.lstrip('/') self.content.label=form.get('label').value self.content.title=form.get('title').value self.content.content=form.get('content').value self.content.active=active static_data = self.content static_data.put() return web.seeother('/'+static_data.name, absolute=True) context['form'] = form return render_template('static_content.html', **context)
def GET(self, slug, post_id): self.init_data(slug, post_id) return render_template('view.html', **context)
def GET(self, post_id=None, action='add'): self.init_data(post_id, action) context['form'] = self.form return render_template('add.html', **context)
def GET(self): context['posts'] = Post.all().filter('active =', True).order('-datetime') return render_template('index.html', **context)
def internalerror(): return web.internalerror(render_template('500.html', **context))
def notfound(): return web.notfound(render_template('404.html', **context))
def GET(self, name, action='view'): self.init_data(name, action) return render_template('static_content.html', **context)