town6.api ========= .. py:module:: town6.api Attributes ---------- .. autoapisummary:: town6.api.T Classes ------- .. autoapisummary:: town6.api.EventApiEndpoint town6.api.NewsApiEndpoint town6.api.TopicApiEndpoint Functions --------- .. autoapisummary:: town6.api.get_geo_location town6.api.get_modified_iso_format Module Contents --------------- .. py:data:: T .. py:function:: get_geo_location(item: onegov.core.orm.mixins.ContentMixin) -> dict[str, Any] .. py:function:: get_modified_iso_format(item: onegov.core.orm.mixins.TimestampMixin) -> str Returns the iso format of the modified or created field of item. :param item: db item e.g. agency, people, membership :return: str iso representation of item last modification .. py:class:: EventApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, str | None] | None = None, page: int | None = None) Bases: :py:obj:`onegov.api.models.ApiEndpoint`\ [\ :py:obj:`onegov.event.models.Occurrence`\ ] An API endpoint. API endpoints wrap collection and do some filter mapping. To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of ``onegov.core.collection.Pagination``. .. py:attribute:: app :type: onegov.town6.app.TownApp .. py:attribute:: endpoint :value: 'events' .. py:property:: collection :type: Any Return an instance of the collection with filters and page set. .. py:method:: item_data(item: onegov.event.models.Occurrence) -> dict[str, Any] Return the data properties of the collection item as a dictionary. For example:: { 'name': 'Paul', 'age': 40 } .. py:method:: item_links(item: onegov.event.models.Occurrence) -> dict[str, Any] Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object. For example:: { 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) } .. py:class:: NewsApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, str | None] | None = None, page: int | None = None) Bases: :py:obj:`onegov.api.models.ApiEndpoint`\ [\ :py:obj:`onegov.org.models.page.News`\ ] An API endpoint. API endpoints wrap collection and do some filter mapping. To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of ``onegov.core.collection.Pagination``. .. py:attribute:: app :type: onegov.town6.app.TownApp .. py:attribute:: endpoint :value: 'news' .. py:attribute:: filters .. py:property:: collection :type: Any Return an instance of the collection with filters and page set. .. py:method:: item_data(item: onegov.org.models.page.News) -> dict[str, Any] Return the data properties of the collection item as a dictionary. For example:: { 'name': 'Paul', 'age': 40 } .. py:method:: item_links(item: onegov.org.models.page.News) -> dict[str, Any] Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object. For example:: { 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) } .. py:class:: TopicApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, str | None] | None = None, page: int | None = None) Bases: :py:obj:`onegov.api.models.ApiEndpoint`\ [\ :py:obj:`onegov.org.models.page.Topic`\ ] An API endpoint. API endpoints wrap collection and do some filter mapping. To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of ``onegov.core.collection.Pagination``. .. py:attribute:: request :type: onegov.town6.request.TownRequest .. py:attribute:: app :type: onegov.town6.app.TownApp .. py:attribute:: endpoint :value: 'topics' .. py:attribute:: filters .. py:property:: collection :type: Any Return an instance of the collection with filters and page set. .. py:method:: item_data(item: onegov.org.models.page.Topic) -> dict[str, Any] Return the data properties of the collection item as a dictionary. For example:: { 'name': 'Paul', 'age': 40 } .. py:method:: item_links(item: onegov.org.models.page.Topic) -> dict[str, Any] Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object. For example:: { 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) }