Пример #1
0
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=(_tooltip_changes_info(changes_info) + "\n" +
                          _("Click here to go to pending changes.")),
        )
    return PageState(text=html.render_span(_("No pending changes"), id_=span_id),
                     url=changelog_url,
                     tooltip_text=_("Click here to see the activation status per site."))
Пример #2
0
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    return PageState(
        top_line=changes_info or _("No pending changes"),
        bottom_line=html.render_a(_("View changes"), href="wato.py?mode=changelog"),
        icon_name="wato_changes" if changes_info else "wato_nochanges",
    )
Пример #3
0
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    tooltip = get_pending_changes_tooltip()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=tooltip,
        )
    return PageState(
        text=html.render_span(_("No pending changes"), id_=span_id),
        icon_name="no_pending_changes",
        url=changelog_url,
        tooltip_text=tooltip,
    )
Пример #4
0
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=ungettext(singular=_("Currently there is one change to activate"),
                                   plural=_("Currently there are %s to activate." % changes_info),
                                   n=int(re.findall(r"\d+", changes_info)[0])) + \
                         "\n" + _("Click here to go to pending changes."),
        )
    return PageState(
        text=html.render_span(_("No pending changes"), id_=span_id),
        url=changelog_url,
        tooltip_text=_("Click here to see the activation status per site."))
Пример #5
0
def _release_switch(major: bool) -> PageState:
    patch_link = html.render_a(_("Patch release"),
                               href=makeuri(request, [], remove_prefix=""),
                               class_="active" if not major else None)
    major_link = html.render_a(_("Major release"),
                               href=makeuri(request, [("major", 1)]),
                               class_="active" if major else None)
    content = html.render_span(patch_link + major_link,
                               id_="release_version_switch")
    return PageState(text=content)
Пример #6
0
def _make_default_page_state(writer: HTMLWriter, request: Request, *,
                             browser_reload: float) -> Optional[PageState]:
    """Create a general page state for all pages without specific one"""
    if not browser_reload:
        return None

    return PageState(
        text=writer.render_span("%d" % browser_reload),
        icon_name="trans",
        css_classes=["reload"],
        url="javascript:document.location.reload()",
        tooltip_text=_("Automatic page reload in %d seconds.") % browser_reload
        + "\n" + _("Click for instant reload."),
    )