Events

This package contains all event-related data models: Event, EventTranslation and RecurrenceRule

Event

class integreat_cms.cms.models.events.event.Event(*args, **kwargs)[source]

Bases: AbstractContentModel

Data model representing an event. Can be directly imported from models.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

translations (Reverse ForeignKey from EventTranslation) – All translations of this event (related name of event)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

archive() None[source]

Archives the event and removes all links of this event from the linkchecker

Return type:

None

copy(user: User) Event[source]

This method creates a copy of this event and all of its translations. This method saves the new event.

Parameters:

user (User) – The user who initiated this copy

Returns:

A copy of this event

Return type:

Event

end_local[source]

Convert the end to local time

Returns:

The end of the event in local time

property fallback_translations_enabled: bool[source]

Whether translations should be returned in the default language if they do not exist

Returns:

Whether fallback translations are enabled

get_occurrences(start: datetime, end: datetime) list[datetime][source]

Get occurrences of the event that overlap with [start, end]. Expects start < end.

Parameters:
  • start (datetime) – the begin of the requested interval.

  • end (datetime) – the end of the requested interval.

Returns:

start datetimes of occurrences of the event that are in the given timeframe

Return type:

list[datetime]

static get_translation_model() ModelBase[source]

Returns the translation model of this content model

Returns:

The class of translations

Return type:

ModelBase

has_location[source]

This property checks whether the event has a physical location (POI).

Returns:

Whether event has a physical location

is_all_day[source]

This property checks whether an event takes place the whole day by checking if start time is minimal and end time is maximal.

Returns:

Whether event takes place all day

is_past[source]

This property checks whether an event lies in the past, including potential future recurrences.

Returns:

Whether event lies in the past

is_recurring[source]

This property checks if the event has a recurrence rule and thereby determines, whether the event is recurring.

Returns:

Whether the event is recurring or not

objects = <django.db.models.manager.ManagerFromEventQuerySet object>[source]

Django manager to access the ORM Use Event.objects.all() to fetch all objects.

The default manager

recurrence_rule[source]

Type: OneToOneField to RecurrenceRule

Recurrence rule (related name: event)

If the event is recurring, the recurrence rule contains all necessary information on the frequency, interval etc. which is needed to calculate the single instances of a recurring event

restore() None[source]

Restores the event and adds all links of this event back

Return type:

None

start_local[source]

Convert the start to local time

Returns:

The start of the event in local time

timezone[source]

The timezone of this event’s region

Returns:

The timezone of this event

class integreat_cms.cms.models.events.event.EventQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: ContentQuerySet

Custom QuerySet to facilitate the filtering by date while taking recurring events into account.

filter_completed(to_date: date | None = None) EventQuerySet[source]

Filter all events that are not ongoing and don’t have any occurrences in the future. This is, per definition, if at least one of the following conditions is true:

  • The event is non-recurring and the end date of the event is before the given date

  • The event is recurring and the recurrence end date is before the given date

Parameters:

to_date (date | None) – The date which should be used for filtering, defaults to the current date

Returns:

The Queryset of events before the given date

Return type:

EventQuerySet

filter_upcoming(from_date: datetime | None = None) EventQuerySet[source]

Filter all events that take place after the given date. This is, per definition, if at least one of the following conditions is true:

  • The end date of the event is the given date or later

  • The event is indefinitely recurring

  • The event is recurring and the recurrence end date is the given date or later

Parameters:

from_date (datetime | None) – The date which should be used for filtering, defaults to the current date

Returns:

The Queryset of events after the given date

Return type:

EventQuerySet

Event Translation

class integreat_cms.cms.models.events.event_translation.EventTranslation(*args, **kwargs)[source]

Bases: AbstractContentTranslation

Data model representing an event translation

Parameters:
  • id (BigAutoField) – Primary key: ID

  • title (CharField) – Title of the event

  • slug (SlugField) – Event link. String identifier without spaces and special characters. Unique per region and language. Leave blank to generate unique parameter from title.

  • status (CharField) – Status

  • content (TextField) – Description

  • currently_in_translation (BooleanField) – Currently in translation. Flag to indicate a translation is being updated by an external translator

  • machine_translated (BooleanField) – Machine translated. Flag to indicate whether a translations is machine translated

  • version (PositiveIntegerField) – Revision

  • minor_edit (BooleanField) – Minor edit. Tick if this change does not require an update of translations in other languages.

  • last_updated (DateTimeField) – Modification date

  • automatic_translation (BooleanField) – Automatic translation. Tick if updating this content should automatically refresh or create its translations.

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

feedback (Reverse ForeignKey from EventFeedback) – All feedback of this event translation (related name of event_translation)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

backend_edit_link[source]

This function returns the absolute url to the editor for this translation

Returns:

The url

static foreign_field() Literal['event'][source]

Returns the string “event” which ist the field name of the reference to the event which the translation belongs to

Returns:

The foreign field name

Return type:

Literal[‘event’]

foreign_object[source]

This property is an alias of the event foreign key and is needed to generalize the slug_utils for all content types

Returns:

The event to which the translation belongs

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

url_infix[source]

Returns the string “events” which is the infix of the url of the event translation object Generates the infix of the url of the event translation object

For information about the components of such an url, see get_absolute_url()

Returns:

The infix of the url

Recurrence Rule

class integreat_cms.cms.models.events.recurrence_rule.RecurrenceRule(*args, **kwargs)[source]

Bases: AbstractBaseModel

Data model representing the recurrence frequency and interval of an event

Parameters:
  • id (BigAutoField) – Primary key: ID

  • frequency (CharField) –

    Frequency. How often the event recurs

    Manage choices in frequency

  • interval (IntegerField) – Repeat every … time(s). The interval in which the event recurs.

  • weekdays_for_weekly (ArrayField) –

    Weekdays. If the frequency is weekly, this field determines on which days the event takes place

    Manage choices in weekdays

  • weekday_for_monthly (IntegerField) –

    Weekday. If the frequency is monthly, this field determines on which days the event takes place

    Manage choices in weekdays

  • week_for_monthly (IntegerField) –

    Week. If the frequency is monthly, this field determines on which week of the month the event takes place

    Manage choices in weeks

  • recurrence_end_date (DateField) – Recurrence end date. If the recurrence is not for an indefinite period, this field contains the end date

Reverse relationships:

Parameters:

event (Reverse OneToOneField from Event) – The event of this recurrence rule (related name of recurrence_rule)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

frequency[source]

Type: CharField

Frequency. How often the event recurs

Choices:

  • DAILY

  • WEEKLY

  • MONTHLY

  • YEARLY

Manage choices in frequency

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <RecurrenceRule: RecurrenceRule object (id)>. It is used for logging.

Returns:

The canonical string representation of the recurrence rule

Return type:

str

iter_after(start_date: date) Iterator[date][source]

Iterate all recurrences after a given start date. This method assumes that weekdays_for_weekly contains at least one member and that weekday_for_monthly and week_for_monthly are not null.

Parameters:

start_date (date) – The date on which the iteration should start

Returns:

An iterator over all dates defined by this recurrence rule

Return type:

Iterator[date]

to_ical_rrule() rrule[source]

Calculates the ical standardized rrule for a recurring rule. See details of the rrule here: https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html

Returns:

The ical rrule for the recurrence rule

Return type:

rrule

to_ical_rrule_string() str[source]

Gets the iCal rrule as a string

Returns:

The ical rrule for the recurrence rule as a string

Return type:

str

week_for_monthly[source]

Type: IntegerField

Week. If the frequency is monthly, this field determines on which week of the month the event takes place

Choices:

  • 1

  • 2

  • 3

  • 4

  • 5

Manage choices in weeks

weekday_for_monthly[source]

Type: IntegerField

Weekday. If the frequency is monthly, this field determines on which days the event takes place

Choices:

  • 0

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

Manage choices in weekdays

weekdays_for_weekly[source]

Type: ArrayField

Weekdays. If the frequency is weekly, this field determines on which days the event takes place

Manage choices in weekdays