Beispiel #1
0
def get_settings(installation, role):

    if role == 'admin':
        sql =  """SELECT * FROM settings INNER JOIN setting_types ON settings.setting_name = setting_types.setting_name WHERE installation = %s ORDER BY `group`"""
        return backend._query(sql, installation)
    else:
        sql = """SELECT * FROM settings INNER JOIN setting_types ON settings.setting_name = setting_types.setting_name WHERE installation = %s AND `role` = %s ORDER BY `group`"""
        return backend._query(sql, installation, role)
Beispiel #2
0
def get_all(serial_number):
    sql = """SELECT * FROM controllers WHERE installation = %s"""
    return backend._query(sql, serial_number)
Beispiel #3
0
def get_customers(username):
    sql = """SELECT * FROM assignees WHERE `user` = %s;"""
    return backend._query(sql,  username)
Beispiel #4
0
def get_assignees(customer_id):
    sql = """SELECT * FROM assignees WHERE customer = %s;"""
    return backend._query(sql, customer_id)
Beispiel #5
0
def get_all():
    return backend._query("SELECT * FROM users")
Beispiel #6
0
def get_users_by_role(role = 'user'):
    sql = """SELECT * from users WHERE role = %s"""
    data =  backend._query(sql, role)
    return {'users': data}
Beispiel #7
0
def get_log_for(installation, fromDate, toDate):
    sql =  """SELECT * FROM log WHERE installation = %s and `time` >= %s and `time` <= %s"""
    return backend._query(sql, installation, fromDate, toDate)
def get_customerless():
    sql = """SELECT * from installations WHERE customer IS NULL;"""
    return backend._query(sql)
Beispiel #9
0
def select_data_like(name, ip):
    return backend._query("""SELECT * FROM sync_queue WHERE data LIKE ? AND data LIKE ?""", '%' + name + '%', '%' + ip + '%')
Beispiel #10
0
def get_by_installation(installation):
    sql = """SELECT * FROM sync_queue WHERE installation = ?"""
    return backend._query(sql, installation)
Beispiel #11
0
def get_all():
    return backend._query("""SELECT * FROM sync_queue WHERE datetime('now') > datetime(last_sync_attempt, '+10 minute') OR last_sync_attempt IS NULL""")
Beispiel #12
0
def get_by_installation_and_type(serial_number, type):
    sql = """SELECT * FROM tags WHERE `installation` = %s AND `type` = %s"""
    return backend._query(sql, serial_number, type)
Beispiel #13
0
def get_all(serial_number, controller_ip):
    sql = """SELECT * FROM tags WHERE `installation` = %s AND `controller_ip` = %s"""
    return backend._query(sql, serial_number, controller_ip)
Beispiel #14
0
def get_pellets_settings(installation):
    sql = """SELECT * FROM settings WHERE installation = %s AND setting_name IN ('internal_pelletslevel_warning', 'external_pelletslevel_warning', 'consumption_rate')"""
    data = backend._query(sql, installation)
    return data
Beispiel #15
0
def get_all(customer_name):
    sql = """SELECT * from installations WHERE customer = %s;"""
    return backend._query(sql, customer_name)
Beispiel #16
0
def get_all_setting_types():
    sql = """SELECT * FROM setting_types"""
    data = backend._query(sql)
    return data
Beispiel #17
0
def get_by_pi_mac(pi_mac):
    sql = """SELECT * FROM users WHERE pi_mac = %s"""
    return backend._query(sql, pi_mac)
Beispiel #18
0
def get_all(serial_number):
    sql = """SELECT * FROM controllers WHERE installation = %s"""
    return backend._query(sql, serial_number)
Beispiel #19
0
def get_all():
    sql = """SELECT * FROM customers"""
    return backend._query(sql)