from mods.db import db, Settings # Имена ключей параметров S_KEY_RECEPTION_LIST = 'reception_list' S_RECEPTION_LIST_DAY_START = 'day_start' S_RECEPTION_LIST_DAY_END = 'day_end' S_RECEPTION_LIST_INTERVAL = 'interval' # Получение параметров def s_get_reception_list(): class RLSettings: day_start = None day_end = None interval = None s = Settings.get(Settings.key == S_KEY_RECEPTION_LIST).val o = RLSettings() o.day_start = s[S_RECEPTION_LIST_DAY_START] o.day_end = s[S_RECEPTION_LIST_DAY_END] o.interval = s[S_RECEPTION_LIST_INTERVAL] return o # Установка параметров def s_set_reception_list(dstart, dend, interval): v = { S_RECEPTION_LIST_DAY_START: dstart, S_RECEPTION_LIST_DAY_END: dend, S_RECEPTION_LIST_INTERVAL: interval } with db.atomic(): q = Settings.select().where(Settings.key == S_KEY_RECEPTION_LIST) if not len(q): Settings.create(key=S_KEY_RECEPTION_LIST, val=v) else: Settings.update(val=v).where(Settings.key == S_KEY_RECEPTION_LIST).execute() ### Инициализация начальных значений параметров # Начальный график приёмов with db.atomic(): q = Settings.select().where(Settings.key == S_KEY_RECEPTION_LIST) if not len(q): s_set_reception_list([8,0], [17,0], 30)