Example #1
0
 def POST(self, id):
     form = self.form()
     page = model.get_page_by_id(int(id))
     if not form.validates():
         return render.edit(page, form)
     model.update_page(int(id), form.d.url, form.d.title, form.d.content)
     raise web.seeother('/')
Example #2
0
 def POST(self, id):
     form = self.form()
     page = model.get_page_by_id(int(id))
     if not form.validates():
         return render.edit(page, form)
     model.update_page(int(id), form.d.url, form.d.title, form.d.content)
     raise web.seeother('/')
Example #3
0
 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')
Example #4
0
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
Example #5
0
 def POST(self):
     form = self.form()
     if form.validates():
         return render.Edit(form)
     model.update_page(form.d.id, form.d.url, form.d.title, form.d.content)
     raise web.seeother("/" + form.d.url)