A general file (image, document, pdf, etc), referenced in the database.


Defines an event.

Module Contents

event.models.event.EventState: typing_extensions.TypeAlias[source]
class event.models.event.EventFile[source]

Bases: onegov.file.File

A general file (image, document, pdf, etc), referenced in the database.

Thanks to the use of Depot files can be seemingly stored in the database (with transaction guarantees), without actually storing it in the database.

class event.models.event.Event[source]

Bases: onegov.core.orm.Base, onegov.event.models.mixins.OccurrenceMixin, onegov.core.orm.mixins.TimestampMixin, onegov.search.SearchableContent, onegov.gis.CoordinatesMixin

Defines an event.

Occurrences are stored in a seperate table containing only a minimal set of attributes from the event. This could also be archieved using postgres directly with dateutil/plpythonu/pg_rrule and materialized views.

Occurrences are only created/updated, if the event is published. Occurrences are created only for this and the next year.

__tablename__ = 'events'[source]
occurrence_dates_year_limit = 2[source]
id: Column[uuid.UUID][source]
state: Column[EventState][source]
description: dict_property[str | None][source]
organizer: dict_property[str | None][source]
organizer_email: dict_property[str | None][source]
organizer_phone: dict_property[str | None][source]
external_event_url: dict_property[str | None][source]
event_registration_url: dict_property[str | None][source]
price: dict_property[str | None][source]
source: dict_property[str | None][source]
source_updated: dict_property[str | None][source]
recurrence: Column[str | None][source]
access: dict_property[str][source]
set_image(content: bytes | IO[bytes] | None, filename: str | None = None) None[source]
set_pdf(content: bytes | IO[bytes] | None, filename: str | None = None) None[source]
set_blob(blob: str, content: bytes | IO[bytes] | None, filename: str | None = None) None[source]

Adds or removes the given blob.

occurrences: relationship[list[Occurrence]][source]
property es_public: bool[source]

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.

property es_skip: bool[source]

Returns True if the indexing of this specific model instance should be skipped.

source_url(request: onegov.core.request.CoreRequest) str | None[source]

Returns an url pointing to the external event if imported.

__setattr__(name: str, value: object) None[source]

Automatically update the occurrences if shared attributes change

property base_query: Query[Occurrence][source]
property latest_occurrence: onegov.event.models.occurrence.Occurrence | None[source]

Returns the occurrence which is presently occurring, the next one to occur or the last occurrence.

future_occurrences(offset: int = 0, limit: int = 10) Query[Occurrence][source]
validate_recurrence(key: str, r: str | None) str | None[source]

Our rrules are quite limited in their complexity. This validator makes sure that is actually the case.

This is a somewhat harsh limit, but it mirrors the actual use of onegov.event at this point. More complex rrules are not handled by the UI, nor is there currently a plan to do so.

Currently supported are weekly recurrences and lists of rdates.

The rational is that people commonly add recurring events on a weekly basis (which is a lot of work for a whole year). Or on a monthly or yearly basis, in which case selection of single dates is acceptable, or even preferrable to complex rrules.

This UI talk doesn’t belong into a module of course, but it is again a reailty that only a strict subset of rules is handled and so we want to catch events which we cannot edit in our UI early if they are imported from outside.

occurrence_dates(limit: bool = True, localize: bool = False) list[datetime.datetime][source]

Returns the start dates of all occurrences.

Returns non-localized dates per default. Limits the occurrences per default to this and the next year.

spawn_occurrence(start: datetime.datetime) onegov.event.models.occurrence.Occurrence[source]

Create an occurrence at the given date, without storing it.

property virtual_occurrence: onegov.event.models.occurrence.Occurrence[source]

Before the event is accepted, there are no real occurrences stored in the database.

At this time it is useful to be able to generate the latest occurence without storing it.

_update_occurrences() None[source]

Updates the occurrences.

Removes all occurrences if the event is not published or no start and end date/time is set. Only occurrences for this and next year are created.

submit() None[source]

Submit the event.

publish() None[source]

Publish the event.

Publishing the event will generate the occurrences.

withdraw() None[source]

Withdraw the event.

Withdraw the event will delete the occurrences.

get_ical_vevents(url: str | None = None) Iterator[vEvent][source]

Returns the event and all its occurrences as icalendar objects.

If the calendar has a bunch of RDATE’s instead of a proper RRULE, we return every occurrence as separate event since most calendars don’t support RDATE’s.

as_ical(url: str | None = None) bytes[source]

Returns the event and all its occurrences as iCalendar string.