- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
def setTariff(id_tariff, id_town, id_base_tariff, tariff_name, min_time, min_distance, min_price, payment_by_distance, payment_by_time, priority, begin_time, end_time, is_weekend, date_begin, date_end, description, isActive):
db = application.db.connect()
cur = db.cursor()
try:
if priority <= 0:
raise RuntimeError("Приоритет должен быть равным, либо выше 0.")
cur.execute("UPDATE public.tariff SET id_town=(%(id_town)s) WHERE id_tariff=(%(id_tariff)s)", {"id_town" : id_town, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET id_base_tariff=(%(id_base_tariff)s) WHERE id_tariff=(%(id_tariff)s)", {"id_base_tariff" : id_base_tariff, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET tariff_name=(%(tariff_name)s) WHERE id_tariff=(%(id_tariff)s)", {"tariff_name" : tariff_name, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET min_time=(%(min_time)s) WHERE id_tariff=(%(id_tariff)s)", {"min_time" : min_time, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET min_distance=(%(min_distance)s) WHERE id_tariff=(%(id_tariff)s)", {"min_distance" : min_distance, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET min_price=(%(min_price)s) WHERE id_tariff=(%(id_tariff)s)", {"min_price" : min_price, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET payment_by_distance=(%(payment_by_distance)s) WHERE id_tariff=(%(id_tariff)s)", {"payment_by_distance" : payment_by_distance, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET payment_by_time=(%(payment_by_time)s) WHERE id_tariff=(%(id_tariff)s)", {"payment_by_time" : payment_by_time, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET priority=(%(priority)s) WHERE id_tariff=(%(id_tariff)s)", {"priority" : priority, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET begin_time=(%(begin_time)s) WHERE id_tariff=(%(id_tariff)s)", {"begin_time" : begin_time, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET end_time=(%(end_time)s) WHERE id_tariff=(%(id_tariff)s)", {"end_time" : end_time, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET is_weekend=(%(is_weekend)s) WHERE id_tariff=(%(id_tariff)s)", {"is_weekend" : is_weekend, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET date_begin=(%(date_begin)s) WHERE id_tariff=(%(id_tariff)s)", {"date_begin" : date_begin, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET date_end=(%(date_end)s) WHERE id_tariff=(%(id_tariff)s)", {"date_end" : date_end, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET description=(%(description)s) WHERE id_tariff=(%(id_tariff)s)", {"description" : description, "id_tariff" : id_tariff})
cur.execute("UPDATE public.tariff SET isActive=(%(isActive)s) WHERE id_tariff=(%(id_tariff)s)", {"isActive" : isActive, "id_tariff" : id_tariff})
db.commit()
return True
except Exception:
db.rollback()
raise
finally:
db.close()
gost 29.04.2016 19:05 # 0
3_14dar 29.04.2016 19:17 # 0
guest 24.06.2016 15:32 # 0
inkanus-gray 24.06.2016 15:39 # 0