Exemple #1
0
def post(name, timestamp):
    if name not in data.POSTS:
        abort(404)
    post = data.get_post(name, timestamp, data.STATE_PUBLISHED)
    if not post:
        abort(404)
    return render_template("post.html", body_id="post", post=post, name=name)
Exemple #2
0
def edit_post_admin(name, timestamp):
    if name not in data.POSTS:
        abort(404)
    post = data.get_post(name, timestamp)
    if not post:
        abort(404)
    return render_template("edit_post.html",
                           body_id="edit-post",
                           post=post,
                           name=name,
                           admin=True)
Exemple #3
0
def edit_post(name, token=None):
    if name not in data.POSTS:
        abort(404)
    if token:
        try:
            timestamp = signer.loads(token)
        except BadSignature:
            abort(401)
        post = data.get_post(name, timestamp)
        if not post:
            abort(404)
    else:
        post = {data.STATE: data.STATE_WAITING}
    if post[data.STATE] == data.STATE_TRASHED:
        return redirect(url_for("rest", name="already_trashed"))
    return render_template("edit_post.html",
                           body_id="edit-post",
                           post=post,
                           name=name,
                           admin=False)
Exemple #4
0
def edit_post(name, token=None):
    if name not in data.POSTS:
        abort(404)
    if token:
        try:
            timestamp = signer.loads(token)
        except BadSignature:
            abort(401)
        post = data.get_post(name, timestamp)
        if not post:
            abort(404)
    else:
        post = {data.STATE: data.STATE_WAITING}
    if post[data.STATE] != data.STATE_WAITING:
        return redirect(url_for('rest', name='already_published'))
    return render_template(
        'edit_post.html',
        body_id='edit-post',
        post=post,
        name=name,
        admin=False,
    )