Ejemplo n.º 1
0
def index(instance_id):
    start_at = request.query.start_at
    end_at = request.query.end_at

    try:
        db = Database('aws')

        Schedule.add(instance_id, start_at, end_at)
        response.set_header('Content-Type', 'application/vnd.api+json')
        return json.dumps({'res': 'success'})
    except Exception as ex:
        abort(500, str(ex))
Ejemplo n.º 2
0
def save(update, context):
    """Return to top level conversation."""
    ud = context.user_data

    schedule = {"time": ud[NEW_TIME][TIME], "duration": ud[NEW_TIME][DURATION]}

    Schedule.create(schedule)

    context.user_data[START_OVER] = True
    start(update, context)

    return END
Ejemplo n.º 3
0
    def __updated(self):
        schedule.clear()
        schedules = Schedule.find_all()
        for sched in schedules:
            schedule.every().days.at(sched[1]).do(self.turn_on, sched[2])

        logger.info("Schedules updated")
Ejemplo n.º 4
0
def index(instance_id):
    try:
        db = Database('aws')

        item = Schedule.remove(instance_id)
        response.set_header('Content-Type', 'application/vnd.api+json')
        return json.dumps({'res': 'success'})
    except Exception as ex:
        abort(500, str(ex))
Ejemplo n.º 5
0
def get_schedule():
    _schedules = []
    schedules = Schedule.find_all()

    for schedule in schedules:
        _schedules.append({
            ID: schedule[0],
            TIME: schedule[1],
            DURATION: schedule[2]
        })

    return _schedules
Ejemplo n.º 6
0
def index():
    db = Database('aws')

    response.set_header('Content-Type', 'application/vnd.api+json')

    data = []
    for item in Schedule.select():
        data.append({
            'id': item.instance_id,
            'start at': str(item.start_at),
            'stop at': str(item.stop_at)
        })

    return json.dumps(data)
Ejemplo n.º 7
0
async def enter_schedule_day_of_week(msg: types.Message, state: FSMContext):
    async with state.proxy() as data:
        if msg.text not in week_days:
            return await msg.answer("Выберите день недели с клавиатуры!",
                                    reply_markup=week_days_kb)
        data["schedule_day_of_week"] = week_days.index(msg.text)
        schedule = Schedule(data["schedule_name"], data["schedule_group_id"],
                            data["schedule_day_of_week"],
                            bool(data["schedule_numerator"]),
                            data["schedule_cabinet"], data["schedule_time"],
                            data["schedule_start_date"],
                            data["schedule_end_date"])
        insert_schedule(schedule)
        await state.finish()
        await msg.answer("Ура! Расписание успешно добавлено!",
                         reply_markup=admin_panel_kb)
Ejemplo n.º 8
0
def remove_schedule(update, context):
    msg_id = int(update.callback_query.data.split('_')[1])
    Schedule.delete_one(msg_id)

    return show_remove_schedule(update, context)