Events
This package contains all event-related data models:
Event
,
EventTranslation
and
RecurrenceRule
Event
- exception integreat_cms.cms.models.events.event.CouldNotBeCopied[source]
Bases:
Exception
Exception for events that can’t be copied
- 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:
id (BigAutoField) – Primary key: ID
created_date (DateTimeField) – Creation date
start (DateTimeField) – Start
end (DateTimeField) – End
archived (BooleanField) – Archived
external_event_id (CharField) – The ID of this event in the external calendar
Relationship fields:
- Parameters:
region (
ForeignKey
toRegion
) – Region (related name:events
)location (
ForeignKey
toPOI
) – Location (related name:events
)recurrence_rule (
OneToOneField
toRecurrenceRule
) –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
icon (
ForeignKey
toMediaFile
) – Icon (related name:events
)external_calendar (
ForeignKey
toExternalCalendar
) – External calendar (related name:events
)
Reverse relationships:
- Parameters:
translations (Reverse
ForeignKey
fromEventTranslation
) – All translations of this event (related name ofevent
)
- 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
- archived[source]
Type:
BooleanField
Archived
- available_translations() Iterator[Any] [source]
This method returns an iterator over all available translations, respecting the fallback_translations_enabled setting.
- Returns:
An iterator over all translations
- Return type:
Iterator[Any]
- backend_edit_link[source]
This function returns the absolute url to the edit form of this region
- Returns:
The url
- backend_translation[source]
This function returns the translation of this content object in the current backend language.
- Returns:
The backend translation of a content object
- best_translation[source]
This function returns the translation of this content object in the current backend language and if it doesn’t exist, it provides a fallback to the translation in the region’s default language.
- Returns:
The “best” translation of a content object for displaying in the backend
- clean()[source]
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- clean_fields(exclude=None)[source]
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- 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
- Raises:
CouldNotBeCopied – When event can’t be copied
- Return type:
- created_date[source]
Type:
DateTimeField
Creation date
- default_public_translation[source]
This function returns the public translation of this content object in the region’s default language.
- Returns:
The default translation of a content object
- default_translation[source]
This function returns the translation of this content object in the region’s default language. Since a content object can only be created by creating a translation in the default language, this is guaranteed to return a object translation (Exception: When the default language tree node is changed to another language after the page has been created, the default translation might not exist).
- Returns:
The default translation of a content object
- property edit_lock_key: tuple[str | int | None, str][source]
This property returns the key that is used to lock this specific content object
- Returns:
A tuple of the id of this object and the classname
- end[source]
Type:
DateTimeField
End
- external_calendar[source]
Type:
ForeignKey
toExternalCalendar
External calendar (related name:
events
)
- external_calendar_id[source]
Internal field, use
external_calendar
instead.
- 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
- full_clean(exclude=None, validate_unique=True, validate_constraints=True)[source]
Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.
- get_locking_user() Any | None [source]
This method returns the user that is currently locking this content object.
- Returns:
The user
- Return type:
Any | None
- get_major_public_translation(language_slug: str) AbstractContentTranslation | None [source]
This function retrieves the newest major public translation of a content object.
- Parameters:
- Returns:
The public translation of a content object
- Return type:
AbstractContentTranslation | None
- get_major_translation(language_slug: str) AbstractContentTranslation | None [source]
This function retrieves the newest major translation of a content object.
- Parameters:
- Returns:
The public translation of a content object
- Return type:
AbstractContentTranslation | None
- classmethod get_model_name_plural() str [source]
Get the plural representation of this model name
- Returns:
The plural model name
- Return type:
- get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)[source]
Finds next instance based on
created_date
. Seeget_next_by_FOO()
for more information.
- get_next_by_end(*, field=<django.db.models.DateTimeField: end>, is_next=True, **kwargs)[source]
Finds next instance based on
end
. Seeget_next_by_FOO()
for more information.
- get_next_by_start(*, field=<django.db.models.DateTimeField: start>, is_next=True, **kwargs)[source]
Finds next instance based on
start
. Seeget_next_by_FOO()
for more information.
- get_occurrences(start: datetime, end: datetime) list[datetime] [source]
Get occurrences of the event that overlap with
[start, end]
. Expectsstart < end
.
- get_prefetched_translations_by_language_slug(attr: str = 'prefetched_translations', **filters: Any) dict[str, AbstractContentTranslation] [source]
This method returns a mapping from language slugs to their latest translations of this object
- Parameters:
attr (str) – Which attribute should be tried to get the prefetched translations [optional, defaults to
"prefetched_translations"
]**filters (Any) – Additional filters to be applied on the translations (e.g. by status)
- Returns:
The prefetched translations by language slug
- Return type:
- get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)[source]
Finds previous instance based on
created_date
. Seeget_previous_by_FOO()
for more information.
- get_previous_by_end(*, field=<django.db.models.DateTimeField: end>, is_next=False, **kwargs)[source]
Finds previous instance based on
end
. Seeget_previous_by_FOO()
for more information.
- get_previous_by_start(*, field=<django.db.models.DateTimeField: start>, is_next=False, **kwargs)[source]
Finds previous instance based on
start
. Seeget_previous_by_FOO()
for more information.
- get_public_or_draft_translation(language_slug: str) AbstractContentTranslation | None [source]
This function retrieves the newest public or draft translation of a content object.
- Parameters:
- Returns:
The public translation of a content object
- Return type:
AbstractContentTranslation | None
- get_public_translation(language_slug: str) AbstractContentTranslation | None [source]
This function retrieves the newest public translation of a content object.
- Parameters:
- Returns:
The public translation of a content object
- Return type:
AbstractContentTranslation | None
- get_repr() str [source]
This overwrites the default Django
__repr__()
method which would return<AbstractContentModel: AbstractContentModel object (id)>
. It is used for logging.- Returns:
The canonical string representation of the content object
- Return type:
- get_translation(language_slug: str) AbstractContentTranslation | None [source]
This function uses the reverse foreign key
self.translations
to get all translations ofself
and filters them to the requestedLanguage
slug.- Parameters:
- Returns:
The translation in the requested
Language
orNone
if no translation exists- Return type:
AbstractContentTranslation | None
- static get_translation_model() ModelBase [source]
Returns the translation model of this content model
- Returns:
The class of translations
- Return type:
ModelBase
- get_translation_state(language_slug: str) str [source]
This function returns the current state of a translation in the given language.
- has_location[source]
This property checks whether the event has a physical location (
POI
).- Returns:
Whether event has a physical location
- hix_ignore: bool = False[source]
Whether the HIX value is ignored (this is
False
by default if not overwritten by a submodel)
- icon[source]
Type:
ForeignKey
toMediaFile
Icon (related name:
events
)
- id[source]
Type:
BigAutoField
Primary key: ID
- invalidate_cached_translations() None [source]
Delete all cached translations and query them from the database again when they are accessed next time.
This is helpful when new translations have been created and the content model should be reused.
- Return type:
None
- 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
- languages[source]
This property returns a list of all
Language
objects, to which a translation exists.- Returns:
The existing languages of this content object
- location[source]
Type:
ForeignKey
toPOI
Location (related name:
events
)
- 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
- prefetched_major_public_translations_by_language_slug[source]
This method returns a mapping from language slugs to their major public translations of this object
- prefetched_major_translations_by_language_slug[source]
This method returns a mapping from language slugs to their major translations of this object
- prefetched_public_or_draft_translations_by_language_slug[source]
This method returns a mapping from language slugs to their public translations of this object
- prefetched_public_translations_by_language_slug[source]
This method returns a mapping from language slugs to their public translations of this object
- prefetched_translations_by_language_slug[source]
This method returns a mapping from language slugs to their latest translations of this object
- Returns:
The prefetched translations by language slug
- public_languages[source]
This property returns a list of all
Language
objects, to which a public translation exists and which are visible in this region.- Returns:
The existing languages of this content object
- recurrence_rule[source]
Type:
OneToOneField
toRecurrenceRule
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
- recurrence_rule_id[source]
Internal field, use
recurrence_rule
instead.
- refresh_from_db(using=None, fields=None)[source]
Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
- region[source]
Type:
ForeignKey
toRegion
Region (related name:
events
)
- save(force_insert=False, force_update=False, using=None, update_fields=None)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)[source]
Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
- serializable_value(field_name)[source]
Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.
Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.
- start[source]
Type:
DateTimeField
Start
- translation_states[source]
This property calculates all translations states of the object
- Returns:
A dictionary containing each language as key and the given translation state as value
- translations[source]
Type: Reverse
ForeignKey
fromEventTranslation
All translations of this event (related name of
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.
- async abulk_create(objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None, unique_fields=None)[source]
- aggregate(*args, **kwargs)[source]
Return a dictionary containing the calculations (aggregation) over the current queryset.
If args is present the expression is passed as a kwarg using the Aggregate object’s default alias.
- async aiterator(chunk_size=2000)[source]
An asynchronous iterator over the results from applying this QuerySet to the database.
- alias(*args, **kwargs)[source]
Return a query set with added aliases for extra data or aggregations.
- all()[source]
Return a new QuerySet that is a copy of the current one. This allows a QuerySet to proxy for a model manager in some cases.
- annotate(*args, **kwargs)[source]
Return a query set in which the returned objects have been annotated with extra data or aggregations.
- bulk_create(objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None, unique_fields=None)[source]
Insert each of the instances into the database. Do not call save() on each of the instances, do not send any pre/post_save signals, and do not set the primary key attribute if it is an autoincrement field (except if features.can_return_rows_from_bulk_insert=True). Multi-table models are not supported.
- bulk_update(objs, fields, batch_size=None)[source]
Update the given fields in each of the given objects in the database.
- complex_filter(filter_obj)[source]
Return a new QuerySet instance with filter_obj added to the filters.
filter_obj can be a Q object or a dictionary of keyword lookup arguments.
This exists to support framework features such as ‘limit_choices_to’, and usually it will be more natural to use other methods.
- count()[source]
Perform a SELECT COUNT() and return the number of records as an integer.
If the QuerySet is already fully cached, return the length of the cached results set to avoid multiple SELECT COUNT(*) calls.
- create(**kwargs)[source]
Create a new object with the given kwargs, saving it to the database and returning the created object.
- dates(field_name, kind, order='ASC')[source]
Return a list of date objects representing all available dates for the given field_name, scoped to ‘kind’.
- datetimes(field_name, kind, order='ASC', tzinfo=None, is_dst=<object object>)[source]
Return a list of datetime objects representing all available datetimes for the given field_name, scoped to ‘kind’.
- defer(*fields)[source]
Defer the loading of data for certain fields until they are accessed. Add the set of deferred fields to any existing set of deferred fields. The only exception to this is if None is passed in as the only parameter, in which case removal all deferrals.
- distinct(*field_names)[source]
Return a new QuerySet instance that will select only distinct results.
- exclude(*args, **kwargs)[source]
Return a new QuerySet instance with NOT (args) ANDed to the existing set.
- explain(*, format=None, **options)[source]
Runs an EXPLAIN on the SQL query this QuerySet would perform, and returns the results.
- extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)[source]
Add extra SQL fragments to the query.
- filter(*args, **kwargs)[source]
Return a new QuerySet instance with the args ANDed to the existing set.
- filter_completed(to_date: date | None = None) Self [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:
Self
- filter_upcoming(from_date: datetime | None = None) Self [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:
Self
- get(*args, **kwargs)[source]
Perform the query and return a single object matching the given keyword arguments.
- get_or_create(defaults=None, **kwargs)[source]
Look up an object with the given kwargs, creating one if necessary. Return a tuple of (object, created), where created is a boolean specifying whether an object was created.
- in_bulk(id_list=None, *, field_name='pk')[source]
Return a dictionary mapping each of the given IDs to the object with that ID. If id_list isn’t provided, evaluate the entire QuerySet.
- iterator(chunk_size=None)[source]
An iterator over the results from applying this QuerySet to the database. chunk_size must be provided for QuerySets that prefetch related objects. Otherwise, a default chunk_size of 2000 is supplied.
- latest(*fields)[source]
Return the latest object according to fields (if given) or by the model’s Meta.get_latest_by.
- only(*fields)[source]
Essentially, the opposite of defer(). Only the fields passed into this method and that are not already specified as deferred are loaded immediately when the queryset is evaluated.
- property ordered[source]
Return True if the QuerySet is ordered – i.e. has an order_by() clause or a default ordering on the model (or is empty).
- prefetch_major_public_translations() ContentQuerySet [source]
Get the queryset including the custom attribute
prefetched_major_public_translations
which contains the latest major (in other words not a minor edit) public translations of each content object in each language- Returns:
The queryset of content objects
- Return type:
- prefetch_major_translations() ContentQuerySet [source]
Get the queryset including the custom attribute
prefetched_major_translations
which contains the latest major (in other words not a minor edit) translations of each content object in each language- Returns:
The queryset of content objects
- Return type:
- prefetch_public_or_draft_translations() ContentQuerySet [source]
Get the queryset including the custom attribute
prefetched_public_or_draft_translations
which contains the latest public or draft translations of each content object in each language- Returns:
The queryset of content objects
- Return type:
- prefetch_public_translations() ContentQuerySet [source]
Get the queryset including the custom attribute
prefetched_public_translations
which contains the latest public translations of each content object in each language- Returns:
The queryset of content objects
- Return type:
Return a new QuerySet instance that will prefetch the specified Many-To-One and Many-To-Many related objects when the QuerySet is evaluated.
When prefetch_related() is called more than once, append to the list of prefetch lookups. If prefetch_related(None) is called, clear the list.
- prefetch_translations(to_attr: str = 'prefetched_translations', **filters: Any) ContentQuerySet [source]
Get the queryset including the custom attribute
to_attr
which contains the latest translations of each content object in each language, optionally filtered by the givenstatus
- Parameters:
to_attr (str) – To which attribute the prefetched translations should be added [optional, defaults to
prefetched_translations
]**filters (Any) – Additional filters to be applied on the translations (e.g. by status)
- Returns:
The queryset of content objects
- Return type:
- select_for_update(nowait=False, skip_locked=False, of=(), no_key=False)[source]
Return a new QuerySet instance that will select objects with a FOR UPDATE lock.
Return a new QuerySet instance that will select related objects.
If fields are specified, they must be ForeignKey fields and only those related objects are included in the selection.
If select_related(None) is called, clear the list.
- update(**kwargs)[source]
Update all elements in the current QuerySet, setting all the given fields to the appropriate values.
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 (TruncatingCharField) – 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:
language (
ForeignKey
toLanguage
) – Language (related name:event_translations
)creator (
ForeignKey
toUser
) – Creator (related name:event_translations
)event (
ForeignKey
toEvent
) – Event (related name:translations
)links (
GenericRelation
toLink
) – Links (related name:event_translation
)
Reverse relationships:
- Parameters:
feedback (Reverse
ForeignKey
fromEventFeedback
) – All feedback of this event translation (related name ofevent_translation
)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- all_versions[source]
This property returns all versions of this translation’s page in its language
- Returns:
All versions of this translation
- automatic_translation[source]
Type:
BooleanField
Automatic translation. Tick if updating this content should automatically refresh or create its translations.
- available_languages_dict[source]
This property checks in which
Language
the content is translated apart fromself.language
It only returns languages which have a public translation, so drafts are not included here. The returned dict has the following format:{ available_translation.language.slug: { 'id': available_translation.id, 'url': available_translation.permalink 'path': available_translation.path }, ... }
- Returns:
A dictionary containing the available languages of a content translation
- backend_edit_link[source]
This function returns the absolute url to the editor for this translation
- Returns:
The url
- base_link[source]
Generates the base link which is the whole url without slug
For information about the components of such an url, see
get_absolute_url()
- Returns:
the base link of the content
- clean()[source]
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- clean_fields(exclude=None)[source]
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- cleanup_autosaves() None [source]
Delete all
AUTO_SAVE
translations older than the second last manual save and renumber all affected versions to be continuous.- Return type:
None
- create_new_version_copy(user: User | None = None) AbstractContentTranslation [source]
Create a new version by copying
- Parameters:
user (User | None)
- Return type:
- creator[source]
Type:
ForeignKey
toUser
Creator (related name:
event_translations
)
- currently_in_translation[source]
Type:
BooleanField
Currently in translation. Flag to indicate a translation is being updated by an external translator
- static default_icon() str | None [source]
- Returns:
The default icon that should be used for this content translation type, or
None
for no icon- Return type:
str | None
- event[source]
Type:
ForeignKey
toEvent
Event (related name:
translations
)
- feedback[source]
Type: Reverse
ForeignKey
fromEventFeedback
All feedback of this event translation (related name of
event_translation
)
- 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
- full_clean(exclude=None, validate_unique=True, validate_constraints=True)[source]
Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.
- full_url[source]
This property returns the full url of this content translation object
- Returns:
The full url
- get_absolute_url() str [source]
Generates the absolute url of the content translation object
Here is an example for demonstrating the components of a page url:
https://integreat.app/augsburg/en/welcome/city-map/attractions/ |-------------------------------------------------------------| full_url |----------------------------------------| get_absolute_url() |-------------------------------------------------| base_link |----------------------------| url_prefix |----------------| url_infix |-----------| slug
Here is an example for demonstrating the components of an event url:
https://integreat.app/augsburg/en/events/test-event/ |--------------------------------------------------| full_url |-----------------------------| get_absolute_url() |---------------------------------------| base_link |------------------| url_prefix |------| url_infix |----------| slug
- Returns:
The absolute url
- Return type:
- get_all_used_slugs() Iterable[str] [source]
- Returns:
All slugs that have been used by at least on version of this translation
- Return type:
Iterable[str]
- classmethod get_model_name_plural() str [source]
Get the plural representation of this model name
- Returns:
The plural model name
- Return type:
- get_next_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=True, **kwargs)[source]
Finds next instance based on
last_updated
. Seeget_next_by_FOO()
for more information.
- get_previous_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=False, **kwargs)[source]
Finds previous instance based on
last_updated
. Seeget_previous_by_FOO()
for more information.
- get_repr() str [source]
This overwrites the default Django
__repr__()
method. It is used for logging.- Returns:
The canonical string representation of the content translation
- Return type:
- get_status_display(*, field=<django.db.models.CharField: status>)[source]
Shows the label of the
status
. Seeget_FOO_display()
for more information.
- hix_enabled[source]
This function returns whether the HIX API is enabled for this instance
- Returns:
Whether HIX is enabled
- hix_ignore[source]
Whether this translation is ignored for HIX calculation
- Returns:
Wether the HIX value is ignored
- hix_sufficient_for_mt[source]
Whether this translation has a sufficient HIX value for machine translations. If it is
None
, machine translations are allowed by default.- Returns:
Whether the HIX value is sufficient for MT
- id[source]
Type:
BigAutoField
Primary key: ID
- is_outdated[source]
This property checks whether a translation is outdated and thus needs a new revision of the content. This happens, when the source translation is updated and the update is no minor_edit.
If the translation is currently being translated, it is considered not outdated.
If the translation’s language is the region’s default language, it is defined to be never outdated.
If the translation’s source translation is already outdated, then the translation itself also is.
If neither the translation nor its source translation have a latest major public translation, it is defined as not outdated.
If neither the translation nor its source translation have a latest major public translation, it is defined as not outdated.
Otherwise, the outdated flag is calculated by comparing the last_updated-field of the translation and its source translation.
- Returns:
Flag to indicate whether the translation is outdated
- is_up_to_date[source]
This property checks whether a translation is up to date. A translation is considered up to date when it is either explicitly set to up-to-date, or has been machine-translated.
- Returns:
Flag which indicates whether a translation is up to date
- language[source]
Type:
ForeignKey
toLanguage
Language (related name:
event_translations
)
- last_updated[source]
Type:
DateTimeField
Modification date
- latest_version[source]
This property is a link to the most recent version of this translation.
- Returns:
The latest revision of the translation
- link_title[source]
This property returns the html that should be used as a title for a link to this translation
- Returns:
The link content
- links[source]
Type: Reverse
GenericRelation
fromEventTranslation
All event translation of this link (related name of
links
)
- machine_translated[source]
Type:
BooleanField
Machine translated. Flag to indicate whether a translations is machine translated
- major_public_source_translation[source]
This property returns the latest major public version of the translation which was used to create the
self
translation. It derives this information from theRegion
’s rootLanguageTreeNode
.
- major_public_version[source]
This property is a link to the most recent major public version of this translation. This is used when translations, which are derived from this translation, check whether they are up to date.
- Returns:
The latest major public revision of the translation
- major_source_translation[source]
This property returns the latest major version of the translation which was used to create the
self
translation. It derives this information from theRegion
’s rootLanguageTreeNode
.
- major_version[source]
This property is a link to the most recent major version of this translation. This is used when translations, which are derived from this translation, check whether they are up to date.
- Returns:
The latest major public revision of the translation
- minor_edit[source]
Type:
BooleanField
Minor edit. Tick if this change does not require an update of translations in other languages.
- path() str [source]
This method returns a human-readable path that should uniquely identify this object within a given region If this content object does not have a hierarchy, just str(obj) should suffice
- Returns:
The path
- Return type:
- public_or_draft_source_translation[source]
This property returns the public and draft translation which was used to create the
self
translation. It derives this information from theRegion
’s rootLanguageTreeNode
.
- public_source_translation[source]
This property returns the public translation which was used to create the
self
translation. It derives this information from theRegion
’s rootLanguageTreeNode
.
- public_version[source]
This property is a link to the most recent public version of this translation. If the translation itself is not public, this property can return a revision which is older than
self
.- Returns:
The latest public revision of the translation
- read_only: bool = False[source]
Whether this object is read-only and not meant to be stored to the database
- refresh_from_db(using=None, fields=None)[source]
Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
- replace_urls(urls_to_replace: dict[str, str], user: User | None = None, commit: bool = True) None [source]
Function to replace links that are in the translation and match the given keyword search
- save(*args: Any, **kwargs: Any) None [source]
This overwrites the default Django
save()
method, to update the last_updated field on changes.- Parameters:
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied kwargs
- Raises:
RuntimeError – When the object was locked for database writes
- Return type:
None
- save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)[source]
Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
- classmethod search(region: Region, language_slug: str, query: str) QuerySet [source]
Searches for all content translations which match the given query in their title or slug. :param region: The current region :param language_slug: The language slug :param query: The query string used for filtering the content translations :return: A query for all matching objects
- serializable_value(field_name)[source]
Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.
Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.
- sitemap_alternates[source]
This property returns the language alternatives of a content translation for the use in sitemaps. Similar to
available_languages_dict()
, but in a slightly different format.- Returns:
A list of dictionaries containing the alternative translations of a content translation
- slug[source]
Type:
SlugField
Event link. String identifier without spaces and special characters. Unique per region and language. Leave blank to generate unique parameter from title.
- source_language[source]
This property returns the source language of this language in this
Region
’s language tree- Returns:
The source language of this translation
- source_translation[source]
This property returns the translation which was used to create the
self
translation. It derives this information from theRegion
’s rootLanguageTreeNode
.
- status[source]
Type:
CharField
Status
Choices:
DRAFT
REVIEW
PUBLIC
AUTO_SAVE
Manage choices in
status
- translation_state[source]
This function returns the current state of a translation in the given language.
- Returns:
A string describing the state of the translation, one of
CHOICES
- 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
- url_prefix[source]
Generates the prefix of the url of the content translation object
For information about the components of such an url, see
get_absolute_url()
- Returns:
The prefix to the url
- validate_unique(exclude=None)[source]
Check unique constraints on the model and raise ValidationError if any failed.
- version[source]
Type:
PositiveIntegerField
Revision
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
fromEvent
) – The event of this recurrence rule (related name ofrecurrence_rule
)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- clean()[source]
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- clean_fields(exclude=None)[source]
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- event[source]
Type: Reverse
OneToOneField
fromEvent
The event of this recurrence rule (related name of
recurrence_rule
)
- frequency[source]
Type:
CharField
Frequency. How often the event recurs
Choices:
DAILY
WEEKLY
MONTHLY
YEARLY
Manage choices in
frequency
- full_clean(exclude=None, validate_unique=True, validate_constraints=True)[source]
Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.
- get_frequency_display(*, field=<django.db.models.CharField: frequency>)[source]
Shows the label of the
frequency
. Seeget_FOO_display()
for more information.
- classmethod get_model_name_plural() str [source]
Get the plural representation of this model name
- Returns:
The plural model name
- Return type:
- 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:
- get_week_for_monthly_display(*, field=<django.db.models.IntegerField: week_for_monthly>)[source]
Shows the label of the
week_for_monthly
. Seeget_FOO_display()
for more information.
- get_weekday_for_monthly_display(*, field=<django.db.models.IntegerField: weekday_for_monthly>)[source]
Shows the label of the
weekday_for_monthly
. Seeget_FOO_display()
for more information.
- id[source]
Type:
BigAutoField
Primary key: ID
- interval[source]
Type:
IntegerField
Repeat every … time(s). The interval in which the event recurs.
- 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 thatweekday_for_monthly
andweek_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]
- recurrence_end_date[source]
Type:
DateField
Recurrence end date. If the recurrence is not for an indefinite period, this field contains the end date
- refresh_from_db(using=None, fields=None)[source]
Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
- save(force_insert=False, force_update=False, using=None, update_fields=None)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)[source]
Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
- serializable_value(field_name)[source]
Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.
Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.
- 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:
- 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:
- validate_unique(exclude=None)[source]
Check unique constraints on the model and raise ValidationError if any failed.
- 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