org.management

Module Contents

Classes

ModelsWithLinksMixin

LinkMigration

PageNameChange

LinkCheck

LinkHealthCheck

Check either internal or external urls for status 200.

class org.management.ModelsWithLinksMixin[source]
property site_collection: onegov.org.models.SiteCollection[source]
fields_with_urls = ('lead', 'text', 'url')[source]
class org.management.LinkMigration(request: onegov.org.request.OrgRequest, old_uri: str, new_uri: str = '')[source]

Bases: ModelsWithLinksMixin

migrate_url(item: object, fields: Iterable[str], test: bool = False, group_by: str | None = None, count_obj: dict[str, dict[str, int]] | None = None) tuple[int, dict[str, dict[str, int]]][source]

Supports replacing url’s and domain names.

migrate_site_collection(test: bool = False) tuple[int, dict[str, dict[str, int]]][source]
class org.management.PageNameChange(request: onegov.org.request.OrgRequest, page: onegov.page.Page, new_name: str)[source]

Bases: ModelsWithLinksMixin

property subpages: list[onegov.page.Page][source]
execute(test: bool = False) int[source]

Executes a page name change. All subpages’ urls are changed by this action. For all subpages, the old and new url must be swapped in all possible fields of all sites of the SiteCollection.

classmethod from_form(model: onegov.page.Page, form: onegov.form.Form) typing_extensions.Self[source]
class org.management.LinkCheck(name: str, link: str, url: str)[source]
ensure_protocol(url: str) str[source]
class org.management.LinkHealthCheck(request: onegov.org.request.OrgRequest, link_type: Literal[internal, external] | None = None, total_timout: float = 30)[source]

Bases: ModelsWithLinksMixin

Check either internal or external urls for status 200.

class Statistic[source]

Bases: NamedTuple

total: int[source]
ok: int[source]
nok: int[source]
error: int[source]
duration: float[source]
property internal_only: bool[source]
property external_only: bool[source]
filter_urls(urls: Sequence[str]) Sequence[str][source]
find_urls() Iterator[tuple[str, str, Sequence[str]]][source]
url_list_generator() Iterator[LinkCheck][source]
unhealthy_urls() tuple[Statistic, Sequence[LinkCheck]][source]

We check the urls in the backend, unless they are internal. In that case, we can not do that since we do not have async support. Otherwise returns the LinkChecks with empty statistics for use in the frontend.