town6.api

Attributes

T

Classes

EventApiEndpoint

An API endpoint.

NewsApiEndpoint

An API endpoint.

Functions

get_geo_location(→ dict[str, Any])

get_modified_iso_format(→ str)

Returns the iso format of the modified or created field of item.

Module Contents

town6.api.T[source]
town6.api.get_geo_location(item: onegov.core.orm.mixins.ContentMixin) dict[str, Any][source]
town6.api.get_modified_iso_format(item: onegov.core.orm.mixins.TimestampMixin) str[source]

Returns the iso format of the modified or created field of item.

Parameters:

item – db item e.g. agency, people, membership

Returns:

str iso representation of item last modification

class town6.api.EventApiEndpoint(app: onegov.core.Framework, extra_parameters: dict[str, str | None] | None = None, page: int | None = None)[source]

Bases: onegov.api.ApiEndpoint[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.

app: onegov.town6.app.TownApp[source]
endpoint = 'events'[source]
property collection: Any[source]

Return an instance of the collection with filters and page set.

item_data(item: onegov.event.models.Occurrence) dict[str, Any][source]

Return the data properties of the collection item as a dictionary.

For example:

{
    'name': 'Paul',
    'age': 40
}

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)
}
class town6.api.NewsApiEndpoint(app: onegov.core.Framework, extra_parameters: dict[str, str | None] | None = None, page: int | None = None)[source]

Bases: onegov.api.ApiEndpoint[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.

app: onegov.town6.app.TownApp[source]
endpoint = 'news'[source]
filters[source]
property collection: Any[source]

Return an instance of the collection with filters and page set.

item_data(item: onegov.org.models.page.News) dict[str, Any][source]

Return the data properties of the collection item as a dictionary.

For example:

{
    'name': 'Paul',
    'age': 40
}

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)
}