Esempio n. 1
def list_users():
    """Get a sorted list of all users."""
    uids  = JsonDB.list_docs("users/by-id")
    users = list()
    for uid in sorted(map(lambda x: int(x), uids)):
        db = get_user(uid=uid)
        if db["role"] == "deleted": continue
    return users
Esempio n. 2
def rebuild_index():
    """Rebuild the index.json if it goes missing."""
    index = {}

    entries = JsonDB.list_docs("blog/entries")
    for post_id in entries:
        db = JsonDB.get("blog/entries/{}".format(post_id))
        update_index(post_id, db, index, False)

    JsonDB.commit("blog/index", index)
    return index
Esempio n. 3
def unsubscribe(thread, email):
    """Unsubscribe an e-mail address from a thread.

    If `thread` is `*`, the e-mail is unsubscribed from all threads."""

    # Which threads to unsubscribe from?
    threads = []
    if thread == "*":
        threads = JsonDB.list_docs("comments/subscribers")
        threads = [thread]

    # Remove them as a subscriber.
    for thread in threads:
        if JsonDB.exists("comments/subscribers/{}".format(thread)):
  "Unsubscribe e-mail address {} from comment thread {}".format(email, thread))
            db = get_subscribers(thread)
            del db[email]
            write_subscribers(thread, db)
Esempio n. 4
def list_pages():
    """Get a list of all existing wiki pages."""
    return JsonDB.list_docs("wiki/pages", recursive=True)