Example #1
0
def edit_user_data(username, email, role):
    response = {'status': True}
    sql = SQLbackend()
    curs = sql.get_cursor()
    curs.execute("UPDATE users SET email_addr = ?, role = ? WHERE username = ?", (email, role, username))
    sql.close_connection()
    return response
Example #2
0
def get_content_blocks():
    sql = SQLbackend()
    curs = sql.get_cursor()
    curs.execute("SELECT id, title FROM content_blocks WHERE category = 'block' ORDER BY weight ASC")
    blocks_arr = curs.fetchall()
    sql.close_connection()
    return blocks_arr
Example #3
0
def management_users_view():
    roles_arr = ['admin', 'editor']
    curr_user = auth.current_user.username
    sql = SQLbackend()
    curs = sql.get_cursor()
    curs.execute("SELECT u.username, u.email_addr, r.role FROM users u NATURAL JOIN roles r WHERE u.username = ? OR r.level < (SELECT r.level FROM users u NATURAL JOIN roles r WHERE u.username = ? ) ORDER BY u.username ASC", (curr_user, curr_user))
    users_arr = curs.fetchall()
    sql.close_connection()
    return bottle.template('./templates/admin_users',
        roles=roles_arr,
        username=curr_user,
        pathname=bottle.request.path,
        users=users_arr
    )
Example #4
0
def management_content_view():
    curr_user = auth.current_user.username
    sql = SQLbackend()
    curs = sql.get_cursor()
    curs.execute("SELECT id, title FROM content_blocks WHERE category = 'header'")
    header_id = curs.fetchall()
    curs.execute("SELECT id, title FROM content_blocks WHERE category = 'footer'")
    footer_id = curs.fetchall()
    sql.close_connection()
    return bottle.template('./templates/admin_content',
        username=curr_user,
        pathname=bottle.request.path,
        blocks = get_content_blocks(),
        header_id = header_id,
        footer_id = footer_id,
    )
Example #5
0
def save_blocks_weights(weights):
    wj = json.loads(weights)
    sql = SQLbackend()
    curs = sql.get_cursor()
    for w in wj:
        id = w.keys()[0]
        weight = w[w.keys()[0]]
        curs.execute("UPDATE content_blocks SET weight = ? WHERE id = ?", (id, weight))
        sql.commit()
    sql.close_connection()