Example #1
0
def edit_post(name):
    if request.POST.get('publish','').strip():
        publish = True
    else:
        publish = False
    if request.POST.get('save','').strip() or publish:
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        try:
            grade = int(request.POST.get('grade', '').strip())
        except:
            grade = None
        url = lib.db.getUrlString()
        lib.db.Page(title=title, grade=grade, content=data, url=url, published=publish, timestamp=today()).put()

        if not publish:
            message =  '<p>The draft has been saved.</p>' 
        else:
            message =  '<p>The page was published.</p>'

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
Example #2
0
def view(name):
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = "Unknown Page"
        p.content = "This page does not exist."
    title = p.title
    content = addLineBreaks(p.content)
    return template('templates/view_page.tpl', title=title, body=content)
Example #3
0
def edit_post(name):
    if request.POST.get('save','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        if url == name:
            message = '<p>The ID %s was successfully updated</p>' % (url)
            #lib.db.q('UPDATE Page SET url = ?, data = ? WHERE url = :1', url)
        else:
            message =  '<p>The new task was inserted into the database, the ID is %s</p>' % (url)
            #lib.db.Page(title=title, content=data, url=url).put()

        lib.db.Page(title=title, content=data, url=url, published=False, timestamp=today()).put()

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
    elif request.POST.get('publish','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = request.POST.get('url', '').strip()

        q = lib.db.Page.gql("WHERE url = :1", name)
        p = q.get()
        lib.db.d(p)

        if url == name:
            message = '<p>The ID %s was successfully updated</p>' % (url)
            #lib.db.q('UPDATE Page SET url = ?, data = ? WHERE url = :1', url)
        else:
            message =  '<p>The new task was inserted into the database, the ID is %s</p>' % (url)
            #lib.db.Page(title=title, content=data, url=url).put()

        lib.db.Page(title=title, content=data, url=url, published=True, timestamp=today()).put()

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
Example #4
0
def show(name):
    if not users.is_current_user_admin():
        pass
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = "Unknown Page"
        p.content = "This page does not exist."
    title = p.title
    content = addLineBreaks(p.content)
    return template('templates/show_page.tpl', title=title, body=content)
Example #5
0
def new_post():
    if request.POST.get('save','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = lib.db.getUrlString()
        lib.db.Page(title=title, content=data, url=url, published=False, timestamp=today()).put()

        message =  '<p>The new page was inserted into the database, \
            the ID is %s</p>' % (url)

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
    elif request.POST.get('publish','').strip():
        title = request.POST.get('title', '').strip()
        data = request.POST.get('data', '').strip()
        url = lib.db.getUrlString()
        lib.db.Page(title=title, content=data, url=url, published=True, timestamp=today()).put()

        message =  '<p>The new page was inserted into the database, \
            the ID is %s</p>' % (url)

        return template('templates/submit.tpl', body=message, 
            data=addLineBreaks(data), title=title, url=url)
Example #6
0
def edit(name):
    q = lib.db.Page.gql("WHERE url = :1", name)
    p = q.get()
    if not p:
        p = Object()
        p.title = ""
        p.content = ""
        p.grade = None
    title = p.title
    content = p.content
    grade = p.grade
    #lib.db.d(p)
    return template('templates/edit_preview.tpl', name=name, body=content, url=name, title=title, grade=grade, data=addLineBreaks(content))