コード例 #1
0
def save_post_admin(name, timestamp):
    if name not in data.POSTS:
        abort(404)
    try:
        data.save_post(
            name, timestamp=timestamp, admin=True,
            form=request.form, files=request.files
        )
    except data.DataException as e:
        abort(e.http_code)
    return redirect(url_for('admin', name=name))
コード例 #2
0
def save_post_admin(name, timestamp):
    if name not in data.POSTS:
        abort(404)
    try:
        data.save_post(
            name,
            timestamp=timestamp,
            admin=True,
            form=request.form,
            files=request.files,
        )
    except data.DataException as e:
        abort(e.http_code)
    if "delete_image" in request.form:
        return redirect(request.url)
    return redirect(url_for("admin", name=name))
コード例 #3
0
def save_post(name, token=None):
    if name not in data.POSTS:
        abort(404)
    if token:
        try:
            timestamp = signer.loads(token)
        except BadSignature:
            abort(401)
    else:
        timestamp = None
    try:
        post = data.save_post(
            name,
            timestamp=timestamp,
            admin=False,
            form=request.form,
            files=request.files,
        )
    except data.DataException as e:
        abort(e.http_code)
    edit_post_url = url_for("edit_post",
                            name=name,
                            token=signer.dumps(post["_timestamp"]))

    if post[data.STATE] == data.STATE_TRASHED:
        return redirect(url_for("rest", name="already_trashed"))
    return render_template("confirmation.html", edit_post_url=edit_post_url)
コード例 #4
0
def save_post(name, token=None):
    if name not in data.POSTS:
        abort(404)
    if token:
        try:
            timestamp = signer.loads(token)
        except BadSignature:
            abort(401)
    else:
        timestamp = None
    try:
        post = data.save_post(
            name, timestamp=timestamp, admin=False,
            form=request.form, files=request.files
        )
    except data.DataException as e:
        abort(e.http_code)
    edit_post_url = url_for(
        'edit_post', name=name, token=signer.dumps(post['_timestamp'])
    )
    return render_template(
        'confirmation.html',
        edit_post_url=edit_post_url
    )