org.models.page =============== .. py:module:: org.models.page Classes ------- .. autoapisummary:: org.models.page.Topic org.models.page.News org.models.page.TopicCollection org.models.page.NewsCollection org.models.page.AtoZPages Module Contents --------------- .. py:class:: Topic(title: str, parent: Self | None = None, **kwargs: Any) Bases: :py:obj:`onegov.page.Page`, :py:obj:`onegov.org.models.traitinfo.TraitInfo`, :py:obj:`onegov.search.SearchableContent`, :py:obj:`onegov.org.models.extensions.AccessExtension`, :py:obj:`onegov.org.models.extensions.PublicationExtension`, :py:obj:`onegov.org.models.extensions.VisibleOnHomepageExtension`, :py:obj:`onegov.org.models.extensions.ContactExtension`, :py:obj:`onegov.org.models.extensions.ContactHiddenOnPageExtension`, :py:obj:`onegov.org.models.extensions.PeopleShownOnMainPageExtension`, :py:obj:`onegov.org.models.extensions.PersonLinkExtension`, :py:obj:`onegov.org.models.extensions.CoordinatesExtension`, :py:obj:`onegov.org.models.extensions.ImageExtension`, :py:obj:`onegov.org.models.extensions.GeneralFileLinkExtension`, :py:obj:`onegov.org.models.extensions.SidebarLinksExtension`, :py:obj:`onegov.org.models.extensions.SidebarContactLinkExtension`, :py:obj:`onegov.org.models.extensions.InlinePhotoAlbumExtension`, :py:obj:`onegov.org.models.extensions.InternalNotesExtension` Defines a generic page. .. py:attribute:: __mapper_args__ .. py:attribute:: fts_type_title Returns the display name for this type of document or a callable which accepts the current request as a single positional argument and returns the display name. .. py:attribute:: fts_public :value: True True if the model is available to be found by the public. If False, only editors/admins will see this object in the search results. .. py:attribute:: fts_properties Returns the type mapping of this model. Each property in the mapping will be read from the model instance. .. py:property:: fts_last_change :type: None The date the document was created/last modified. Returning `None` indicates that the document's age/recency must not influence search ranking: the item should be treated as equally relevant regardless of how old it is. .. py:property:: fts_skip :type: bool True if the indexing of this specific model instance should be skipped. .. py:attribute:: lead :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: text .. py:attribute:: url :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: as_card :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: height :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: lead_when_child :type: onegov.core.orm.mixins.dict_property[bool] .. py:attribute:: keywords :type: onegov.core.orm.mixins.dict_property[list[str]] .. py:property:: deletable :type: bool True if this page may be deleted. .. py:property:: editable :type: bool .. py:property:: url_changeable :type: bool Open for all topics, even root ones. .. py:property:: paste_target :type: Topic | News The page that should be used as parent for content pasting when paste is called on the current page (self). This is usually just self. If the paste action should put the content alongside the current page, it would be the parent. .. py:property:: allowed_subtraits :type: tuple[str, ...] A list of traits that this page may contain. .. py:method:: is_supported_trait(trait: str) -> bool Returns true if the given trait is supported by this type This doesn't mean that the trait may be added to this page, it serves as a simple sanity check, returning True if the combination of the type and the trait make any sense at all. .. py:method:: get_form_class(trait: str, action: str, request: onegov.org.request.OrgRequest) -> type[onegov.org.forms.LinkForm | onegov.org.forms.PageForm | onegov.org.forms.IframeForm] Returns the form class for the given trait, action. .. py:class:: News(title: str, parent: Self | None = None, **kwargs: Any) Bases: :py:obj:`onegov.page.Page`, :py:obj:`onegov.org.models.traitinfo.TraitInfo`, :py:obj:`onegov.search.SearchableContent`, :py:obj:`onegov.org.models.extensions.AccessExtension`, :py:obj:`onegov.org.models.extensions.PublicationExtension`, :py:obj:`onegov.org.models.extensions.VisibleOnHomepageExtension`, :py:obj:`onegov.org.models.extensions.ContactExtension`, :py:obj:`onegov.org.models.extensions.ContactHiddenOnPageExtension`, :py:obj:`onegov.org.models.extensions.PeopleShownOnMainPageExtension`, :py:obj:`onegov.org.models.extensions.PersonLinkExtension`, :py:obj:`onegov.org.models.extensions.CoordinatesExtension`, :py:obj:`onegov.org.models.extensions.ImageExtension`, :py:obj:`onegov.org.models.extensions.GeneralFileLinkExtension`, :py:obj:`onegov.org.models.extensions.DeletableContentExtension`, :py:obj:`onegov.org.models.extensions.InlinePhotoAlbumExtension`, :py:obj:`onegov.org.models.extensions.PushNotificationExtension` Defines a generic page. .. py:attribute:: __mapper_args__ .. py:attribute:: fts_type_title Returns the display name for this type of document or a callable which accepts the current request as a single positional argument and returns the display name. .. py:attribute:: fts_public :value: True True if the model is available to be found by the public. If False, only editors/admins will see this object in the search results. .. py:property:: fts_last_change :type: datetime.datetime The date the document was created/last modified. Returning `None` indicates that the document's age/recency must not influence search ranking: the item should be treated as equally relevant regardless of how old it is. .. py:attribute:: filter_years :value: None .. py:attribute:: filter_tags :value: None .. py:attribute:: page :value: None .. py:attribute:: lead :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: text .. py:attribute:: url :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: hashtags :type: onegov.core.orm.mixins.dict_property[list[str]] .. py:attribute:: push_notifications :type: onegov.core.orm.mixins.dict_property[list[list[str]]] .. py:attribute:: send_push_notifications_to_app :type: onegov.core.orm.mixins.dict_property[bool] .. py:attribute:: sent_notifications :type: sqlalchemy.orm.Mapped[onegov.org.models.PushNotification] .. py:method:: content_observer(content: dict[str, Any]) -> None .. py:property:: absorb :type: str Alias for :attr:`path`. This is a convenience feature for Morepath if a path is absorbed. See ``_ .. py:property:: deletable :type: bool .. py:property:: editable :type: bool .. py:property:: url_changeable :type: bool Open for all topics, even root ones. .. py:property:: paste_target :type: Topic | News The page that should be used as parent for content pasting when paste is called on the current page (self). This is usually just self. If the paste action should put the content alongside the current page, it would be the parent. .. py:property:: allowed_subtraits :type: tuple[str, ...] A list of traits that this page may contain. .. py:method:: is_supported_trait(trait: str) -> bool Returns true if the given trait is supported by this type This doesn't mean that the trait may be added to this page, it serves as a simple sanity check, returning True if the combination of the type and the trait make any sense at all. .. py:method:: get_root_page_form_class(request: onegov.org.request.OrgRequest) -> type[onegov.form.Form] .. py:method:: get_form_class(trait: str, action: str, request: onegov.org.request.OrgRequest) -> type[onegov.form.Form | onegov.org.forms.PageForm] Returns the form class for the given trait, action. .. py:method:: push_notifications_were_sent_before() -> bool .. py:class:: TopicCollection(request: onegov.org.request.OrgRequest, page: int = 0, term: str | None = None) Bases: :py:obj:`onegov.core.collection.Pagination`\ [\ :py:obj:`Topic`\ ], :py:obj:`onegov.core.orm.abstract.AdjacencyListCollection`\ [\ :py:obj:`Topic`\ ] Use it like this: from onegov.page import TopicCollection topics = TopicCollection(session) .. py:attribute:: __listclass__ The list class this collection handles. Must inherit from :class:`AdjacencyList`. .. py:attribute:: request .. py:attribute:: session .. py:attribute:: page :value: 0 .. py:attribute:: term :value: None .. py:property:: q :type: str | None .. py:method:: subset() -> sqlalchemy.orm.Query[Topic] Returns an SQLAlchemy query containing all records that should be considered for pagination. .. py:property:: page_index :type: int The current page index (starting at 0). .. py:method:: page_by_index(index: int) -> Self Returns the page at the given index. A page here means an instance of the class inheriting from the ``Pagination`` base class. .. py:class:: NewsCollection(request: onegov.core.request.CoreRequest, page: int = 0, term: str | None = None, filter_years: list[int] | None = None, filter_tags: list[str] | None = None, root: News | None = None) Bases: :py:obj:`onegov.core.collection.Pagination`\ [\ :py:obj:`News`\ ], :py:obj:`onegov.core.orm.abstract.AdjacencyListCollection`\ [\ :py:obj:`News`\ ] Use it like this: from onegov.page import NewsCollection news = NewsCollection(request) .. py:attribute:: __listclass__ The list class this collection handles. Must inherit from :class:`AdjacencyList`. .. py:attribute:: batch_size :value: 40 .. py:attribute:: absorb :value: '' .. py:attribute:: request .. py:attribute:: session .. py:attribute:: page :value: 0 .. py:attribute:: term :value: None .. py:attribute:: filter_years :value: [] .. py:attribute:: filter_tags :value: [] .. py:property:: q :type: str | None .. py:property:: root :type: News | None .. py:method:: __clipboard_object__(request: onegov.core.request.CoreRequest) -> News | None .. py:property:: access :type: str .. py:method:: subset() -> sqlalchemy.orm.Query[News] Returns an SQLAlchemy query containing all records that should be considered for pagination. .. py:method:: sticky() -> sqlalchemy.orm.Query[News] Get a query with only the sticky news. .. py:property:: page_index :type: int The current page index (starting at 0). .. py:method:: __eq__(other: object) -> bool Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages. .. py:method:: page_by_index(index: int) -> Self Returns the page at the given index. A page here means an instance of the class inheriting from the ``Pagination`` base class. .. py:method:: for_year(year: int) -> Self .. py:method:: for_tag(tag: str) -> Self .. py:property:: all_years :type: list[int] .. py:property:: all_tags :type: list[str] .. py:method:: __link_alias__() -> str .. py:class:: AtoZPages(request: onegov.org.request.OrgRequest) Bases: :py:obj:`onegov.org.models.atoz.AtoZ`\ [\ :py:obj:`Topic`\ ] .. py:method:: get_title(item: Topic) -> str .. py:method:: get_items() -> list[Topic]