Exemple #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)
Exemple #2
0
def get_all(serial_number):
    sql = """SELECT * FROM controllers WHERE installation = %s"""
    return backend._query(sql, serial_number)
Exemple #3
0
def get_customers(username):
    sql = """SELECT * FROM assignees WHERE `user` = %s;"""
    return backend._query(sql,  username)
Exemple #4
0
def get_assignees(customer_id):
    sql = """SELECT * FROM assignees WHERE customer = %s;"""
    return backend._query(sql, customer_id)
Exemple #5
0
def get_all():
    return backend._query("SELECT * FROM users")
Exemple #6
0
def get_users_by_role(role = 'user'):
    sql = """SELECT * from users WHERE role = %s"""
    data =  backend._query(sql, role)
    return {'users': data}
Exemple #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)
Exemple #9
0
def select_data_like(name, ip):
    return backend._query("""SELECT * FROM sync_queue WHERE data LIKE ? AND data LIKE ?""", '%' + name + '%', '%' + ip + '%')
Exemple #10
0
def get_by_installation(installation):
    sql = """SELECT * FROM sync_queue WHERE installation = ?"""
    return backend._query(sql, installation)
Exemple #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""")
Exemple #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)
Exemple #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)
Exemple #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
def get_all(customer_name):
    sql = """SELECT * from installations WHERE customer = %s;"""
    return backend._query(sql, customer_name)
Exemple #16
0
def get_all_setting_types():
    sql = """SELECT * FROM setting_types"""
    data = backend._query(sql)
    return data
Exemple #17
0
def get_by_pi_mac(pi_mac):
    sql = """SELECT * FROM users WHERE pi_mac = %s"""
    return backend._query(sql, pi_mac)
Exemple #18
0
def get_all(serial_number):
    sql = """SELECT * FROM controllers WHERE installation = %s"""
    return backend._query(sql, serial_number)
Exemple #19
0
def get_all():
    sql = """SELECT * FROM customers"""
    return backend._query(sql)