event.models.event
Attributes
Classes
A general file (image, document, pdf, etc), referenced in the database. |
|
Defines an event. |
Module Contents
- event.models.event.EventState: TypeAlias = Literal['initiated', 'submitted', 'published', 'withdrawn'][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.
- 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]
- access: dict_property[str][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]
- es_properties[source]
Returns the type mapping of this model. Each property in the mapping will be read from the model instance.
The returned object needs to be a dict or an object that provides a
to_dict
method.Internally, onegov.search stores differing languages in different indices. It does this automatically through langauge detection, or by manually specifying a language.
Note that objects with multiple languages are not supported (each object is supposed to have exactly one language).
Onegov.search will automatically insert the right analyzer for types like these.
There’s currently only limited support for properties here, namely objects and nested mappings do not work! This is going to be added in the future though.
- 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.