Exemplo n.º 1
0
def update_setting(setting, installationValue, sync=True):
    print("update: ", setting)
    prev = Installations_dao.get_setting_by_name(installationValue, setting['setting_name'])
    updated = Installations_dao.update_setting(setting, installationValue)
    if updated and sync:
        sync = sync_queue_dao.insert_params(installationValue, 'settings', 'update', setting, prev)
    return updated
Exemplo n.º 2
0
def create(serial_number, model, name="", customer=1):
    new_installation = dict()
    new_installation['serial_number'] = serial_number
    new_installation['model'] = model
    new_installation['name'] = name
    new_installation['customer'] = customer
    installation = get(serial_number)
    if installation:
        installation['customer'] = customer
        installation['model'] = model
        installation['name'] = name
        return Installations_dao.update(installation)
    return Installations_dao.create(new_installation)
Exemplo n.º 3
0
def get(serial_number, internal=False):
    res = None
    installation = Installations_dao.get(serial_number)
    if installation:
        if internal or authentication.allow_viewing(installation.get('customer')):
            res = installation
    return res
Exemplo n.º 4
0
def factory_reset(installation_id,setting_name):
    if installation_id:
        setting = get_setting(installation_id, setting_name)
        default = Installations_dao.get_default_for(setting_name)
        setting['value'] = default
        update_setting(setting, installation_id)
    else:
        return NameError("Error factory reset")
    return installation_id
Exemplo n.º 5
0
def is_registered(serial_number):
    return Installations_dao.get(serial_number) is not None
Exemplo n.º 6
0
def factory_reset_all(installationId):
    settings = Installations_dao.get_settings(installationId)
    for setting in settings:
        setting['value'] = setting['default_value']
        update_setting(setting, setting['installation'])
    return installationId
Exemplo n.º 7
0
def get_setting(installationValue, setting_name):
    return Installations_dao.get_setting_by_name(installationValue, setting_name)
Exemplo n.º 8
0
def get_all():
    return Installations_dao.get_all()
Exemplo n.º 9
0
def update_installation(installation):
    res = None
    if get(installation.get('serial_number')):
        res = Installations_dao.update(installation)
    return res
Exemplo n.º 10
0
def get_settings(serial_number):
    res = None
    if get(serial_number):
        res = Installations_dao.get_settings(serial_number)
    return res
Exemplo n.º 11
0
def get_by_customer(customer_id):
    res = None
    if authentication.allow_viewing(customer_id):
        res = Installations_dao.get_all(customer_id)
    return res
Exemplo n.º 12
0
def delete_installation(serial_number):
    res = False
    installation = get(serial_number)
    if installation:
        res = Installations_dao.delete(serial_number)
    return res
Exemplo n.º 13
0
def register(serial_number, model, name=""):
    new_installation = dict()
    new_installation['serial_number'] = serial_number
    new_installation['model'] = model
    new_installation['name'] = name
    return Installations_dao.register(new_installation)
Exemplo n.º 14
0
def get_customerless():
    return Installations_dao.get_customerless()