org.management ============== .. py:module:: org.management Classes ------- .. autoapisummary:: org.management.ModelsWithLinksMixin org.management.LinkMigration org.management.PageNameChange org.management.LinkCheck org.management.LinkHealthCheck Module Contents --------------- .. py:class:: ModelsWithLinksMixin .. py:attribute:: fields_with_urls :value: ('lead', 'text', 'url') .. py:attribute:: request :type: onegov.org.request.OrgRequest .. py:property:: site_collection :type: onegov.org.models.SiteCollection .. py:class:: LinkMigration(request: onegov.org.request.OrgRequest, old_uri: str, new_uri: str = '') Bases: :py:obj:`ModelsWithLinksMixin` .. py:attribute:: request .. py:attribute:: old_uri .. py:attribute:: new_uri :value: '' .. py:attribute:: use_domain .. py:method:: migrate_url(item: object, fields: collections.abc.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]]] Supports replacing url's and domain names. .. py:method:: migrate_site_collection(test: bool = False) -> tuple[int, dict[str, dict[str, int]]] .. py:class:: PageNameChange(request: onegov.org.request.OrgRequest, page: onegov.page.Page, new_name: str) Bases: :py:obj:`ModelsWithLinksMixin` .. py:attribute:: request .. py:attribute:: page .. py:attribute:: new_name .. py:property:: subpages :type: list[onegov.page.Page] .. py:method:: execute(test: bool = False) -> int 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. .. py:method:: from_form(model: onegov.page.Page, form: onegov.form.Form) -> Self :classmethod: .. py:class:: LinkCheck(name: str, link: str, url: str) .. py:attribute:: name .. py:attribute:: link .. py:attribute:: url .. py:attribute:: status :type: int | None :value: None .. py:attribute:: message :type: str | None :value: None .. py:method:: ensure_protocol(url: str) -> str .. py:class:: LinkHealthCheck(request: onegov.org.request.OrgRequest, link_type: Literal['internal', 'external', ''] | None = None, total_timout: float = 30) Bases: :py:obj:`ModelsWithLinksMixin` Check either internal or external urls for status 200. .. py:class:: Statistic Bases: :py:obj:`NamedTuple` .. py:attribute:: total :type: int .. py:attribute:: ok :type: int .. py:attribute:: nok :type: int .. py:attribute:: error :type: int .. py:attribute:: duration :type: float .. py:attribute:: request .. py:attribute:: link_type :value: None .. py:attribute:: domain .. py:attribute:: extractor .. py:attribute:: timeout .. py:property:: internal_only :type: bool .. py:property:: external_only :type: bool .. py:method:: internal_link(url: str) -> bool .. py:method:: filter_urls(urls: collections.abc.Sequence[str]) -> collections.abc.Sequence[str] .. py:method:: find_urls() -> collections.abc.Iterator[tuple[str, str, collections.abc.Sequence[str]]] .. py:method:: url_list_generator() -> collections.abc.Iterator[LinkCheck] .. py:method:: unhealthy_urls() -> tuple[Statistic, collections.abc.Sequence[LinkCheck]] 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.