예제 #1
0
def calendar():
    scheduling_form = SchedulingForm(request.form)
    scheduling_form.job.choices = choices('Job')
    tasks = {}
    for task in fetch_all('Task'):
        # javascript dates range from 0 to 11, we must account for that by
        # substracting 1 to the month for the date to be properly displayed in
        # the calendar
        if not task.start_date:
            continue
        python_month = search(
            r'.*-(\d{2})-.*',
            task.aps_date('start_date')
        ).group(1)
        month = '{:02}'.format((int(python_month) - 1) % 12)
        js_date = [int(i) for i in sub(
            r"(\d+)-(\d+)-(\d+) (\d+):(\d+).*",
            r"\1," + month + r",\3,\4,\5",
            task.aps_date('start_date')
        ).split(',')]
        tasks[task.name] = {**task.serialized, **{'date': js_date}}
    return render_template(
        'calendar.html',
        tasks=tasks,
        scheduling_form=scheduling_form
    )
예제 #2
0
def task_management():
    scheduling_form = SchedulingForm(request.form)
    scheduling_form.job.choices = Job.choices()
    return render_template(f'task_management.html',
                           fields=task_public_properties,
                           tasks=Task.serialize(),
                           scheduling_form=scheduling_form)
예제 #3
0
파일: routes.py 프로젝트: victor051/eNMS
def calendar() -> dict:
    tasks = {}
    for task in fetch_all("Task"):
        # javascript dates range from 0 to 11, we must account for that by
        # substracting 1 to the month for the date to be properly displayed in
        # the calendar
        date = task.next_run_time
        if not date:
            continue
        python_month = search(r".*-(\d{2})-.*", date).group(1)  # type: ignore
        month = "{:02}".format((int(python_month) - 1) % 12)
        js_date = [
            int(i) for i in sub(r"(\d+)-(\d+)-(\d+) (\d+):(\d+).*", r"\1," +
                                month + r",\3,\4,\5", date).split(",")
        ]
        tasks[task.name] = {**task.serialized, **{"date": js_date}}
    return dict(tasks=tasks, scheduling_form=SchedulingForm(request.form))
예제 #4
0
def task_management():
    return dict(fields=task_public_properties,
                tasks=serialize('Task'),
                scheduling_form=SchedulingForm(request.form))
예제 #5
0
파일: routes.py 프로젝트: victor051/eNMS
def task_management() -> dict:
    return dict(fields=task_table_properties,
                scheduling_form=SchedulingForm(request.form))