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` Defines a generic page. .. py:attribute:: __mapper_args__ .. py:attribute:: es_type_name :value: 'topics' Returns the unique type name of the model. .. 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:property:: es_skip :type: bool Returns True if the indexing of this specific model instance should be skipped. .. py:property:: es_public :type: bool Returns 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:: deletable :type: bool Returns 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 Returns the page that should be used as parent for the content pasting if 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, Ellipsis] Returns 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.NewsletterExtension`, :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:: es_type_name :value: 'news' Returns the unique type name of the model. .. 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:: filter_years :type: list[int] :value: [] .. py:attribute:: filter_tags :type: list[str] :value: [] .. 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:property:: es_public :type: bool Returns 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: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 Returns the page that should be used as parent for the content pasting if 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, Ellipsis] Returns 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:: for_year(year: int) -> News .. py:method:: for_tag(tag: str) -> News .. py:method:: news_query_for(self: News | onegov.org.request.PageMeta, limit: int | None = 2, published_only: bool = True, session: sqlalchemy.orm.Session | None = None) -> sqlalchemy.orm.Query[News] :classmethod: .. py:method:: news_query(limit: int | None = 2, published_only: bool = True) -> sqlalchemy.orm.Query[News] .. py:property:: all_years :type: list[int] .. py:property:: all_tags :type: list[str] .. py:method:: push_notifications_were_sent_before() -> bool .. py:class:: TopicCollection(session: sqlalchemy.orm.Session, page: int = 0, only_public: bool = False) Bases: :py:obj:`onegov.core.collection.Pagination`\ [\ :py:obj:`Topic`\ ], :py:obj:`onegov.page.collection.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:: session .. py:attribute:: page :value: 0 .. py:attribute:: only_public :value: False .. 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 Returns 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(session: sqlalchemy.orm.Session, page: int = 0, only_public: bool = False) Bases: :py:obj:`onegov.core.collection.Pagination`\ [\ :py:obj:`News`\ ], :py:obj:`onegov.page.collection.AdjacencyListCollection`\ [\ :py:obj:`News`\ ] Use it like this: from onegov.page import NewsCollection news = NewsCollection(session) .. py:attribute:: __listclass__ The list class this collection handles. Must inherit from :class:`AdjacencyList`. .. py:attribute:: session .. py:attribute:: page :value: 0 .. py:attribute:: only_public :value: False .. py:method:: subset() -> sqlalchemy.orm.Query[News] Returns an SQLAlchemy query containing all records that should be considered for pagination. .. py:property:: page_index :type: int Returns 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:: AtoZPages(request: onegov.org.request.OrgRequest) Bases: :py:obj:`onegov.org.models.atoz.AtoZ`\ [\ :py:obj:`Topic`\ ] Abstract base class for generic types. A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:: class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc. This class can then be used as follows:: def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default .. py:method:: get_title(item: Topic) -> str .. py:method:: get_items() -> list[Topic]