예제 #1
0
def alarms_delete(alarm_id):
    # get alarm info
    row = util.getRowFromTableById('alarm',
                                   int(alarm_id),
                                   columns="account_id")

    # is row there?
    if not row:
        abort(404, "Alarm " + str(alarm_id) + " not found")

    if request.user.id == int(row["account_id"]) or request.user.is_power_user():
        # get alarm info
        row = util.getRowFromTableById('alarm', int(alarm_id))

        # return error if row not found
        if not row:
            abort(404, "Alarm not found.")

        # delete alarm
        util.deleteRowFromTableById("alarm", alarm_id)

    # TODO: manually delete all alarm contacts associated with this alarm? No delete cascade will take care of it.
    else:
        unauthorized()

    return HTTPResponse(output="Alarm deleted.", status=204)
예제 #2
0
def accounts_delete(id):
    row = util.getRowFromTableById('account', int(id), checkEnabled=True)
    if (row):
        if int(row['privilege_id']) > request.user.privilege_id:
            unauthorized()
        else:
            util.deleteRowFromTableById('account',
                                        int(id),
                                        deleteIsDisable=True)
            return HTTPResponse(output="Account removed.", status=204)
    else:
        abort(404, 'Account not found.')
예제 #3
0
def luts_mc_maxtemp_delete(id):
    conn = util.getConn()
    row = util.getRowFromTableById('mc_maxtemp_lut', id, conn=conn)
    if not row:
        abort(404, 'LUT not found.')

    cur = conn.cursor()

    util.deleteRowFromTableById("mc_maxtemp_lut", id, cursor=cur)

    general = util.getRowFromTableById("general_config", 1, conn=conn)
    if not general["default_mc_maxtemp_lut_id"]:
        cur.execute(
            'UPDATE general_config SET default_mc_maxtemp_lut_id=(SELECT id FROM mc_maxtemp_lut ORDER BY id LIMIT 1)'
        )
    conn.commit()
    cur.close()
    conn.close()
    return HTTPResponse(output='LUT Deleted', status=204)
예제 #4
0
    # get fill info
    try:
        fid = int(fill_id)
    except ValueError, e:
        abort(404, "Fill not found.")
    from_subscription_id = request.params.get("from_subscription_id", None)
    conn = util.getConn()
    cur = conn.cursor()
    row = util.getRowFromTableById('fill', fid, conn=conn)

    # return error if row not found
    if not row:
        abort(404, "Fill not found.")

    # delete alarm
    util.deleteRowFromTableById("fill", fill_id, cursor=cur)

    if row["air_begin_datetime"]:
        year = row["air_begin_datetime"].year
    else:
        year = row["filled_datetime"].year

    subscription_handler.add_event(
        {
            "key": 'fill',
            "year": year,
            "ids": [fid],
            "type": "delete",
            "when": util.getDateFromParam("now")
        }, conn, cur, from_subscription_id)
예제 #5
0
def sensor_mirrors_delete(id):
    row = util.getRowFromTableById("sensor_mirror", int(id))
    if not row:
        abort(404, "Sensor mirror not found.")
    util.deleteRowFromTableById("sensor_mirror", int(id))
    return HTTPResponse(output="Sensor mirror deleted", status=204)
예제 #6
0
def air_deductions_del(id):
    air_deduct = util.getRowFromTableById("air_deduct", id)
    if not air_deduct:
        abort(404, 'Air deduct not found')
    util.deleteRowFromTableById("air_deduct", id)
    return HTTPResponse(output="Air Deduction Deleted", status=202)
예제 #7
0
def devices_delete(id):
    row = util.getRowFromTableById("device", int(id))
    if not row:
        abort(404, "Device not found.")
    util.deleteRowFromTableById("device", int(id))
    return HTTPResponse(output="Device deleted.", status=204)