Ejemplo n.º 1
0
def pool_management():
    pool_object_form = PoolObjectsForm(request.form)
    pool_object_form.devices.choices = choices('Device')
    pool_object_form.links.choices = choices('Link')
    return render_template('pool_management.html',
                           form=AddPoolForm(request.form),
                           pool_object_form=pool_object_form,
                           names=pretty_names,
                           fields=pool_table_properties,
                           pools=serialize('Pool'))
Ejemplo n.º 2
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
    )
Ejemplo n.º 3
0
def syslog_automation():
    log_automation_form = LogAutomationForm(request.form)
    log_automation_form.jobs.choices = choices('Job')
    return render_template('log_automation.html',
                           log_automation_form=log_automation_form,
                           names=pretty_names,
                           fields=('name', 'source', 'content'),
                           log_rules=serialize('LogRule'))
Ejemplo n.º 4
0
def task_management():
    scheduling_form = SchedulingForm(request.form)
    scheduling_form.job.choices = choices('Job')
    return render_template(
        f'task_management.html',
        fields=task_public_properties,
        tasks=serialize('Task'),
        scheduling_form=scheduling_form
    )
Ejemplo n.º 5
0
def admninistration():
    database_filtering_form = DatabaseFilteringForm(request.form)
    database_filtering_form.pool.choices = choices('Pool')
    try:
        tacacs_server = get_one('TacacsServer')
    except NoResultFound:
        tacacs_server = None
    try:
        syslog_server = get_one('SyslogServer')
    except NoResultFound:
        syslog_server = None
    return render_template(
        'administration.html',
        database_filtering_form=database_filtering_form,
        geographical_parameters_form=GeographicalParametersForm(request.form),
        gotty_parameters_form=GottyParametersForm(request.form),
        notification_parameters_form=NotificationParametersForm(request.form),
        parameters=get_one('Parameters'),
        tacacs_form=TacacsServerForm(request.form),
        syslog_form=SyslogServerForm(request.form),
        tacacs_server=tacacs_server,
        syslog_server=syslog_server)
Ejemplo n.º 6
0
 def __init__(self, model, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.choices = choices(model)
Ejemplo n.º 7
0
 def __init__(self, model: str, *args: Any, **kwargs: Any) -> None:
     super().__init__(*args, **kwargs)
     self.choices = choices(model)
Ejemplo n.º 8
0
 def __init__(self, model, *args, **kwargs):
     property = kwargs.pop('property', 'id')
     super().__init__(*args, **kwargs)
     self.choices = choices(model, property)