Пример #1
0
def delete_page(name):
    """Completely delete a wiki page."""
    name = name.strip("/")
    path = "wiki/pages/{}".format(name)

    if JsonDB.exists(path):
        logger.info("Delete Wiki page {}".format(name))
        JsonDB.delete(path)

    return True
Пример #2
0
def delete_page(name):
    """Completely delete a wiki page."""
    name = name.strip("/")
    path = "wiki/pages/{}".format(name)

    if JsonDB.exists(path):
        logger.info("Delete Wiki page {}".format(name))
        JsonDB.delete(path)

    return True
Пример #3
0
def delete_entry(post_id):
    """Remove a blog entry."""
    # Fetch the blog information.
    index = get_index()
    post  = get_entry(post_id)
    if post is None:
        logger.warning("Can't delete post {}, it doesn't exist!".format(post_id))

    # Delete the post.
    JsonDB.delete("blog/entries/{}".format(post_id))

    # Update the index cache.
    del index[str(post_id)] # Python JSON dict keys must be strings, never ints
    JsonDB.commit("blog/index", index)
Пример #4
0
def update_user(uid, data):
    """Update the user's data."""
    if not exists(uid=uid):
        raise Exception("Can't update user {}: doesn't exist!".format(uid))

    db = get_user(uid=uid)

    # Change of username?
    if "username" in data and len(data["username"]) and data["username"] != db["username"]:
        JsonDB.delete("users/by-name/{}".format(db["username"]))
        JsonDB.commit("users/by-name/{}".format(data["username"]), dict(
            uid=int(uid),
        ))

    db.update(data)
    JsonDB.commit("users/by-id/{}".format(uid), db)
Пример #5
0
def delete_entry(post_id):
    """Remove a blog entry."""
    # Fetch the blog information.
    index = get_index()
    post = get_entry(post_id)
    if post is None:
        logger.warning(
            "Can't delete post {}, it doesn't exist!".format(post_id))

    # Delete the post.
    JsonDB.delete("blog/entries/{}".format(post_id))

    # Update the index cache.
    del index[str(
        post_id)]  # Python JSON dict keys must be strings, never ints
    JsonDB.commit("blog/index", index)
Пример #6
0
def delete_user(uid):
    """Delete a user account."""
    if not exists(uid=uid):
        return

    db = get_user(uid=uid)
    username = db["username"]

    # Mark the account deleted.
    update_user(uid, dict(
        username="",
        name="",
        role="deleted",
        password="******",
    ))

    # Delete their username.
    JsonDB.delete("users/by-name/{}".format(username))
Пример #7
0
def write_subscribers(thread, subs):
    """Save the subscribers to the DB."""
    if len(subs.keys()) == 0:
        return JsonDB.delete("comments/subscribers/{}".format(thread))
    return JsonDB.commit("comments/subscribers/{}".format(thread), subs)
Пример #8
0
def write_comments(thread, comments):
    """Save the comments DB."""
    if len(comments.keys()) == 0:
        return JsonDB.delete("comments/threads/{}".format(thread))
    return JsonDB.commit("comments/threads/{}".format(thread), comments)
Пример #9
0
def write_subscribers(thread, subs):
    """Save the subscribers to the DB."""
    if len(subs.keys()) == 0:
        return JsonDB.delete("comments/subscribers/{}".format(thread))
    return JsonDB.commit("comments/subscribers/{}".format(thread), subs)
Пример #10
0
def write_comments(thread, comments):
    """Save the comments DB."""
    if len(comments.keys()) == 0:
        return JsonDB.delete("comments/threads/{}".format(thread))
    return JsonDB.commit("comments/threads/{}".format(thread), comments)