def POST(self, page=None): data = self.page_form() if data.validates(): d = data.d cur = model.get_page(page) print d if cur: model.update_page(page, d.title, d.position, d.pagesize, int(d.draft)) else: model.add_page(d.name, d.title, int(d.position), int(d.pagesize), int(d.draft)) raise web.seeother('/page')
def add_page(title_id=None): """ Post method that adds a new page to database """ ## Confirm args exist if 'auth' not in request.form: abort(401) if 'title' not in request.form: abort(406) if 'data' not in request.form: abort(406) ## Check token if not model.check_token(request.form['auth']): abort(401) if title_id: ## If flagged edit existing post title = request.form['title'] #title = title.title() title_id = model.update_page(title_id, title, request.form['data']) else: ## Not flagged add new post title = request.form['title'] title = title.title() page_id = model.add_page(title, request.form['data']) ## Save all posted files to static dir files = request.files for filename in files: files[filename].save(f"{static_path}/{filename}") return "OK", 200
def make_page(page, title, position): model.add_page(page,title, position, draft=0)