示例#1
0
文件: views.py 项目: Ruxton92/Leggera
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
示例#2
0
文件: views.py 项目: Ruxton92/Leggera
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
示例#3
0
文件: views.py 项目: Ruxton92/Leggera
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()
示例#4
0
文件: views.py 项目: Ruxton92/Leggera
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
    )
示例#5
0
文件: views.py 项目: Ruxton92/Leggera
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,
    )