Exemplo n.º 1
0
def _render_werk_table_options():
    werk_table_options = {}  # type: Dict[str, Any]

    for name, height, vs, default_value in _werk_table_option_entries():
        value = default_value
        try:
            if html.request.has_var("wo_set"):
                value = vs.from_html_vars("wo_" + name)
                vs.validate_value(value, "wo_" + name)
        except MKUserError as e:
            html.user_error(e)

        werk_table_options.setdefault(name, value)

    html.begin_foldable_container("werks",
                                  "options",
                                  isopen=True,
                                  title=_("Searching and Filtering"),
                                  indent=False)
    html.begin_form("werks")
    html.hidden_field("wo_set", "set")
    html.begin_floating_options("werks", is_open=True)
    for name, height, vs, default_value in _werk_table_option_entries():
        html.render_floating_option(name, height, "wo_", vs,
                                    werk_table_options[name])
    html.end_floating_options(reset_url=html.makeuri([], remove_prefix=""))
    html.hidden_fields()
    html.end_form()
    html.end_foldable_container()

    from_date, until_date = Timerange().compute_range(
        werk_table_options["date"])[0]
    werk_table_options["date_range"] = from_date, until_date

    return werk_table_options
Exemplo n.º 2
0
def render_availability_options(what):
    if html.request.var("_reset"):
        config.user.save_file("avoptions", {})
        html.request.del_vars("avo_")
        html.request.del_var("avoptions")

    avoptions = availability.get_default_avoptions()

    # Users of older versions might not have all keys set. The following
    # trick will merge their options with our default options.
    avoptions.update(config.user.load_file("avoptions", {}))

    is_open = False
    html.begin_form("avoptions")
    html.hidden_field("avoptions", "set")
    avoption_entries = availability.get_avoption_entries(what)
    if html.request.var("avoptions") == "set":
        for name, height, _show_in_reporting, vs in avoption_entries:
            try:
                avoptions[name] = vs.from_html_vars("avo_" + name)
                vs.validate_value(avoptions[name], "avo_" + name)
            except MKUserError as e:
                html.add_user_error(e.varname, e)
                is_open = True

    if html.request.var("_unset_logrow_limit") == "1":
        avoptions["logrow_limit"] = 0

    range_vs = None
    for name, height, _show_in_reporting, vs in avoption_entries:
        if name == 'rangespec':
            range_vs = vs

    try:
        range_, range_title = range_vs.compute_range(avoptions["rangespec"])
        avoptions["range"] = range_, range_title
    except MKUserError as e:
        html.add_user_error(e.varname, e)

    if html.has_user_errors():
        html.show_user_errors()

    html.begin_floating_options("avoptions", is_open)
    for name, height, _show_in_reporting, vs in avoption_entries:
        html.render_floating_option(name, height, "avo_", vs,
                                    avoptions.get(name))
    html.end_floating_options(reset_url=html.makeuri(
        [("_reset", "1")],
        remove_prefix="avo_",
        delvars=["apply", "filled_in"],
    ))

    html.hidden_fields()
    html.end_form()

    if html.form_submitted():
        config.user.save_file("avoptions", avoptions)

    return avoptions
Exemplo n.º 3
0
def _render_werk_options_form(werk_table_options: Dict[str, Any]) -> HTML:
    with output_funnel.plugged():
        html.begin_form("werks")
        html.hidden_field("wo_set", "set")

        _show_werk_options_controls()

        html.open_div(class_="side_popup_content")
        for name, height, vs, _default_value in _werk_table_option_entries():
            html.render_floating_option(name, height, "wo_", vs, werk_table_options[name])
        html.close_div()

        html.hidden_fields()
        html.end_form()

        return HTML(output_funnel.drain())
Exemplo n.º 4
0
    def _display_audit_log_options(self):
        if display_options.disabled(display_options.C):
            return

        html.begin_form("options", method="GET")

        self._show_audit_log_options_controls()

        html.open_div(class_="side_popup_content")
        html.show_user_errors()

        for name, vs in self._audit_log_options():
            html.render_floating_option(name, "single", "options_", vs, self._options[name])

        html.close_div()

        html.hidden_fields()
        html.end_form()