Pages

This package contains page-related data models:

Abstract Base Page

class integreat_cms.cms.models.pages.abstract_base_page.AbstractBasePage(*args, **kwargs)[source]

Bases: AbstractContentModel

Abstract base class for page and imprint page models.

Parameters:
  • created_date (DateTimeField) – Creation date

  • explicitly_archived (BooleanField) – Explicitly archived. Whether or not the page is explicitly archived

Relationship fields:

Parameters:

region (ForeignKey to Region) – Region

__init__(*args, **kwargs)[source]
async adelete(using=None, keep_parents=False)[source]
archived[source]

This is an alias of explicitly_archived. Used for hierarchical pages to implement a more complex notion of explicitly and implicitly archived pages (see archived()).

Returns:

Whether or not this page is archived

async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
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]

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

classmethod check(**kwargs)[source]
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.

created_date[source]

Type: DateTimeField

Creation date

date_error_message(lookup_type, field_name, unique_for)[source]
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

delete(using=None, keep_parents=False)[source]
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

explicitly_archived[source]

Type: BooleanField

Explicitly archived. Whether or not the page is explicitly archived

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

classmethod from_db(db, field_names, values)[source]
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_constraints()[source]
get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

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:

str

get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)[source]

Finds next instance based on created_date. See get_next_by_FOO() for more information.

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:

dict[str, AbstractContentTranslation]

get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)[source]

Finds previous instance based on created_date. See get_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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

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:

str

get_translation(language_slug: str) AbstractContentTranslation | None[source]

This function uses the reverse foreign key self.translations to get all translations of self and filters them to the requested Language slug.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

The translation in the requested Language or None if no translation exists

Return type:

AbstractContentTranslation | None

get_translation_state(language_slug: str) str[source]

This function returns the current state of a translation in the given language.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

A string describing the state of the translation, one of CHOICES

Return type:

str

hix_ignore: bool = False[source]

Whether the HIX value is ignored (this is False by default if not overwritten by a submodel)

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

languages[source]

This property returns a list of all Language objects, to which a translation exists.

Returns:

The existing languages of this content object

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

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

Custom model manager for content objects

property pk[source]
prefetched_major_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_major_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_or_draft_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

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

prepare_database_save(field)[source]
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

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 to Region

Region

region_id[source]

Internal field, use region instead.

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.

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

unique_error_message(model_class, unique_check)[source]
validate_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

Abstract Base Page Translation

class integreat_cms.cms.models.pages.abstract_base_page_translation.AbstractBasePageTranslation(*args, **kwargs)[source]

Bases: AbstractContentTranslation

Data model representing a page or imprint page translation

Parameters:
  • title (CharField) – Title

  • slug (SlugField) – 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) – Content

  • 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:
__init__(*args, **kwargs)[source]
async adelete(using=None, keep_parents=False)[source]
all_versions[source]

This property returns all versions of this translation’s page in its language

Returns:

All versions of this translation

async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
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 from self.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

Generates the url of the edit page for the content

To be implemented in the inheriting model

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

classmethod check(**kwargs)[source]
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.

content[source]

Type: TextField

Content

creator[source]

Type: ForeignKey to User

Creator

creator_id[source]

Internal field, use creator instead.

currently_in_translation[source]

Type: BooleanField

Currently in translation. Flag to indicate a translation is being updated by an external translator

date_error_message(lookup_type, field_name, unique_for)[source]
delete(using=None, keep_parents=False)[source]
static foreign_field() Literal['page'][source]

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

Returns:

The foreign field name

Return type:

Literal[‘page’]

foreign_object[source]

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

Returns:

The page to which the translation belongs

classmethod from_db(db, field_names, values)[source]
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:

str

get_constraints()[source]
get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

classmethod get_model_name_plural() str[source]

Get the plural representation of this model name

Returns:

The plural model name

Return type:

str

get_next_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=True, **kwargs)[source]

Finds next instance based on last_updated. See get_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. See get_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:

str

get_status_display(*, field=<django.db.models.CharField: status>)[source]

Shows the label of the status. See get_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_score = None[source]

The HIX score is None if not overwritten by a submodel

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:

Wether the HIX value is sufficient for MT

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 not outdated and not being translated at the moment.

Returns:

Flag which indicates whether a translation is up to date

language[source]

Type: ForeignKey to Language

Language

language_id[source]

Internal field, use language instead.

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

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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.

page[source]

The page the translation belongs to

To be implemented in the inheriting model

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:

str

property pk[source]
prepare_database_save(field)[source]
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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

public_source_translation[source]

This property returns the public translation which was used to create the self translation. It derives this information from the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

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

readable_title[source]

Get the title of a page translation including the title in the best translation

Returns:

The readable title of the page translation

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(*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

Parameters:
  • region (Region) –

  • language_slug (str) –

  • query (str) –

Return type:

QuerySet

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.

short_url[source]

This property calculates the short url dynamically

To be implemented in the inheriting model

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

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

title[source]

Type: CharField

Title

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

unique_error_message(model_class, unique_check)[source]
url_infix[source]

Generates the infix of the url of the content translation object

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

To be implemented in the inheriting model

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_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

version[source]

Type: PositiveIntegerField

Revision

Imprint Page

class integreat_cms.cms.models.pages.imprint_page.ImprintPage(*args, **kwargs)[source]

Bases: AbstractContentModel

Data model representing an imprint.

Parameters:

Relationship fields:

Parameters:

region (ForeignKey to Region) – Region (related name: imprints)

Reverse relationships:

Parameters:

translations (Reverse ForeignKey from ImprintPageTranslation) – All translations of this imprint (related name of page)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
silent_variable_failure = True[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(*args, **kwargs)[source]
async adelete(using=None, keep_parents=False)[source]
async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
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]

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

classmethod check(**kwargs)[source]
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.

created_date[source]

Type: DateTimeField

Creation date

date_error_message(lookup_type, field_name, unique_for)[source]
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

delete(using=None, keep_parents=False)[source]
property edit_lock_key: tuple[int, str][source]

This property returns the key that is used to lock this specific content object This overwrites edit_lock_key()

Returns:

A tuple of the region slug and the classname

fallback_translations_enabled: bool = True[source]

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

classmethod from_db(db, field_names, values)[source]
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_constraints()[source]
get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

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:

str

get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)[source]

Finds next instance based on created_date. See get_next_by_FOO() for more information.

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:

dict[str, AbstractContentTranslation]

get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)[source]

Finds previous instance based on created_date. See get_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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

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:

str

get_translation(language_slug: str) AbstractContentTranslation | None[source]

This function uses the reverse foreign key self.translations to get all translations of self and filters them to the requested Language slug.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

The translation in the requested Language or None 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.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

A string describing the state of the translation, one of CHOICES

Return type:

str

hix_ignore: bool = False[source]

Whether the HIX value is ignored (this is False by default if not overwritten by a submodel)

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

languages[source]

This property returns a list of all Language objects, to which a translation exists.

Returns:

The existing languages of this content object

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

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

Custom model manager for content objects

property pk[source]
prefetched_major_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_major_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_or_draft_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

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

prepare_database_save(field)[source]
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

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 to Region

Region (related name: imprints)

region_id[source]

Internal field, use region instead.

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.

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 from ImprintPageTranslation

All translations of this imprint (related name of page)

unique_error_message(model_class, unique_check)[source]
validate_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

Imprint Page Translation

class integreat_cms.cms.models.pages.imprint_page_translation.ImprintPageTranslation(*args, **kwargs)[source]

Bases: AbstractBasePageTranslation

Data model representing a imprint translation

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

  • title (CharField) – Title

  • status (CharField) – Status

  • content (TextField) – Content

  • 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:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
silent_variable_failure = True[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(*args, **kwargs)[source]
async adelete(using=None, keep_parents=False)[source]
all_versions[source]

This property returns all versions of this translation’s page in its language

Returns:

All versions of this translation

async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
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 from self.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

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

Returns:

The url

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

classmethod check(**kwargs)[source]
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.

content[source]

Type: TextField

Content

creator[source]

Type: ForeignKey to User

Creator (related name: imprint_translations)

creator_id[source]

Internal field, use creator instead.

currently_in_translation[source]

Type: BooleanField

Currently in translation. Flag to indicate a translation is being updated by an external translator

date_error_message(lookup_type, field_name, unique_for)[source]
delete(using=None, keep_parents=False)[source]
static foreign_field() Literal['page'][source]

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

Returns:

The foreign field name

Return type:

Literal[‘page’]

foreign_object[source]

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

Returns:

The page to which the translation belongs

classmethod from_db(db, field_names, values)[source]
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:

str

get_constraints()[source]
get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

classmethod get_model_name_plural() str[source]

Get the plural representation of this model name

Returns:

The plural model name

Return type:

str

get_next_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=True, **kwargs)[source]

Finds next instance based on last_updated. See get_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. See get_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:

str

get_status_display(*, field=<django.db.models.CharField: status>)[source]

Shows the label of the status. See get_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_score = None[source]

The HIX score is None if not overwritten by a submodel

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:

Wether 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 not outdated and not being translated at the moment.

Returns:

Flag which indicates whether a translation is up to date

language[source]

Type: ForeignKey to Language

Language (related name: imprint_translations)

language_id[source]

Internal field, use language instead.

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

Type: Reverse GenericRelation from ImprintPageTranslation

All imprint 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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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.

objects = <django.db.models.Manager object>[source]
page[source]

Type: ForeignKey to ImprintPage

Imprint (related name: translations)

page_id[source]

Internal field, use page instead.

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:

str

property pk[source]
prepare_database_save(field)[source]
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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

public_source_translation[source]

This property returns the public translation which was used to create the self translation. It derives this information from the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

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

readable_title[source]

Get the title of a page translation including the title in the best translation

Returns:

The readable title of the page translation

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(*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

Parameters:
  • region (Region) –

  • language_slug (str) –

  • query (str) –

Return type:

QuerySet

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.

short_url[source]

This function returns the absolute short url to the imprint translation

Returns:

The short url of an imprint translation

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

property slug: str[source]

For compatibility with the other page translations, a slug property is useful.

Returns:

pseudo slug for the imprint translation

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

title[source]

Type: CharField

Title

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

unique_error_message(model_class, unique_check)[source]
url_infix[source]

Generates the infix of the url of the imprint 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_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

version[source]

Type: PositiveIntegerField

Revision

Page

class integreat_cms.cms.models.pages.page.Page(*args, **kwargs)[source]

Bases: AbstractTreeNode, AbstractBasePage

Data model representing a page.

Parameters:

Relationship fields:

Parameters:
  • parent (ForeignKey to Page) – Parent page (related name: children)

  • region (ForeignKey to Region) – Region (related name: pages)

  • icon (ForeignKey to MediaFile) – Icon (related name: pages)

  • mirrored_page (ForeignKey to Page) – Mirrored page. If the page embeds live content from another page, it is referenced here. (related name: mirroring_pages)

  • organization (ForeignKey to Organization) – Responsible organization. This allows all members of the organization to edit and publish this page. (related name: pages)

  • authors (ManyToManyField to User) – Authors. A list of users who have the permission to edit this specific page. Only has effect if these users do not have the permission to edit pages anyway. (related name: editable_pages)

  • editors (ManyToManyField to User) – Editors. A list of users who have the permission to publish this specific page. Only has effect if these users do not have the permission to publish pages anyway. (related name: publishable_pages)

  • embedded_offers (ManyToManyField to OfferTemplate) – Page based offer. Select an offer provider whose offers should be displayed on this page. (related name: pages)

Reverse relationships:

Parameters:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
silent_variable_failure = True[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(*args, **kwargs)[source]
add_child(**kwargs: Any) AbstractTreeNode[source]

Adds a child to the node

Parameters:

**kwargs (Any) – The supplied keyword arguments

Returns:

The new child

Return type:

AbstractTreeNode

classmethod add_root(**kwargs)[source]

Adds a root node to the tree.

add_sibling(pos: str | None = None, **kwargs: Any) AbstractTreeNode[source]

Adds a new node as a sibling to the current node object

Parameters:
  • pos (str | None) – The position of the new sibling

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The new sibling

Return type:

AbstractTreeNode

async adelete(using=None, keep_parents=False)[source]
api_token[source]

Type: CharField

API access token. API token to allow writing content to translations.

archive() None[source]

Archives the page and removes all links of this page and all its subpages from the linkchecker

Return type:

None

archived[source]

A hierarchical page is archived either explicitly if explicitly_archived=True or implicitly if one of its ancestors is explicitly archived.

Returns:

Whether or not this page is archived

async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
authors[source]

Type: ManyToManyField to User

Authors. A list of users who have the permission to edit this specific page. Only has effect if these users do not have the permission to edit pages anyway. (related name: editable_pages)

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]

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

cached_children[source]

Get all cached children

Returns:

A list of all the node’s cached children

cached_parent[source]

Get the parent node of the current node object. Caches the result in the object itself to help in loops.

Returns:

The parent of the node

classmethod check(**kwargs)[source]
children[source]

Type: Reverse ForeignKey from Page

All children of this page (related name of parent)

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.

created_date[source]

Type: DateTimeField

Creation date

date_error_message(lookup_type, field_name, unique_for)[source]
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

delete(*args, **kwargs)[source]

Removes a node and all it’s descendants.

depth[source]

Type: PositiveIntegerField

Depth

classmethod dump_bulk(parent=None, keep_ids=True)[source]

Dumps a tree branch to a python data structure.

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

editors[source]

Type: ManyToManyField to User

Editors. A list of users who have the permission to publish this specific page. Only has effect if these users do not have the permission to publish pages anyway. (related name: publishable_pages)

embedded_offers[source]

Type: ManyToManyField to OfferTemplate

Page based offer. Select an offer provider whose offers should be displayed on this page. (related name: pages)

explicitly_archived[source]

Type: BooleanField

Explicitly archived. Whether or not the page is explicitly archived

explicitly_archived_ancestors[source]

This returns all of the page’s ancestors which are archived.

Returns:

The list of archived ancestors

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

classmethod find_problems() None[source]

Checks for problems in the tree structure.

This dummy method definition exists to silence pylint’s warning: Method ‘find_problems’ is abstract in class ‘Node’ but is not overridden (abstract-method)

Return type:

None

classmethod fix_tree() None[source]

Solves problems that can appear when transactions are not used and a piece of code breaks, leaving the tree in an inconsistent state.

This dummy method definition exists to silence pylint’s warning: Method ‘fix_tree’ is abstract in class ‘Node’ but is not overridden (abstract-method)

Return type:

None

classmethod from_db(db, field_names, values)[source]
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_ancestors()[source]
Returns:

A queryset containing the current node object’s ancestors, starting by the root node and descending to the parent.

classmethod get_annotated_list(parent=None, max_depth=None)[source]

Gets an annotated list from a tree branch.

Parameters:
  • parent – The node whose descendants will be annotated. The node itself will be included in the list. If not given, the entire tree will be annotated.

  • max_depth – Optionally limit to specified depth

classmethod get_annotated_list_qs(qs)[source]

Gets an annotated list from a queryset.

get_cached_ancestors(include_self: bool = False) list[AbstractTreeNode][source]

Get the cached ancestors of a specific node

Parameters:

include_self (bool) – Whether the current node should be included in the result (defaults to False)

Returns:

A QuerySet containing the current node object’s ancestors, starting by the root node and descending to the parent.

Return type:

list[AbstractTreeNode]

get_cached_descendants(include_self: bool = False) list[AbstractTreeNode][source]

Get the cached descendants of a specific node

Parameters:

include_self (bool) – Whether the current node should be included in the result (defaults to False)

Returns:

A QuerySet containing the current node object’s ancestors, starting by the root node and descending to the parent.

Return type:

list[AbstractTreeNode]

get_children()[source]
Returns:

A queryset of all the node’s children

get_children_count()[source]
Returns:

The number of the node’s children

get_constraints()[source]
classmethod get_database_vendor(action)[source]

returns the supported database vendor used by a treebeard model when performing read (select) or write (update, insert, delete) operations.

Parameters:

actionread or write

Returns:

postgresql, mysql or sqlite

get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

get_depth()[source]
Returns:

the depth (level) of the node

get_descendant_count()[source]
Returns:

the number of descendants of a node.

get_descendants()[source]
Returns:

A queryset of all the node’s descendants as DFS, doesn’t include the node itself

classmethod get_descendants_group_count(parent=None)[source]

Helper for a very common case: get a group of siblings and the number of descendants (not only children) in every sibling.

Parameters:

parent – The parent of the siblings to return. If no parent is given, the root nodes will be returned.

Returns:

A list (NOT a Queryset) of node objects with an extra attribute: descendants_count.

get_first_child()[source]
Returns:

The leftmost node’s child, or None if it has no children.

classmethod get_first_root_node()[source]
Returns:

The first root node in the tree or None if it is empty.

get_first_sibling()[source]
Returns:

The leftmost node’s sibling, can return the node itself if it was the leftmost sibling.

classmethod get_foreign_keys()[source]

Get foreign keys and models they refer to, so we can pre-process the data for load_bulk

get_last_child()[source]
Returns:

The rightmost node’s child, or None if it has no children.

classmethod get_last_root_node()[source]
Returns:

The last root node in the tree or None if it is empty.

get_last_sibling()[source]
Returns:

The rightmost node’s sibling, can return the node itself if it was the rightmost sibling.

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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

Returns:

The public translation of a content object

Return type:

AbstractContentTranslation | None

get_mirrored_page_translation(language_slug: str) Any | None[source]

Mirrored content always includes the live content from another page. This content needs to be added when delivering content to end users.

Parameters:

language_slug (str) – The slug of the requested Language

Returns:

The content of a mirrored page

Return type:

Any | None

classmethod get_model_name_plural() str[source]

Get the plural representation of this model name

Returns:

The plural model name

Return type:

str

get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)[source]

Finds next instance based on created_date. See get_next_by_FOO() for more information.

get_next_sibling()[source]
Returns:

The next node’s sibling, or None if it was the rightmost sibling.

get_non_archived_children() Iterator[Page][source]

This method returns all children of this page that are neither explicitly archived nor implicitly archived

Returns:

The non-archived children

Return type:

Iterator[Page]

get_parent(update=False)[source]
Returns:

the parent node of the current node object. Caches the result in the object itself to help in loops.

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:

dict[str, AbstractContentTranslation]

get_prev_sibling()[source]
Returns:

The previous node’s sibling, or None if it was the leftmost sibling.

get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)[source]

Finds previous instance based on created_date. See get_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:

language_slug (str) – The slug of the requested Language

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:

language_slug (str) – The slug of the requested Language

Returns:

The public translation of a content object

Return type:

AbstractContentTranslation | None

classmethod get_region_root_nodes(region_slug: str) NS_NodeQuerySet[source]

Get all root nodes of a specific region

Parameters:

region_slug (str) – The slug of the requested Region

Returns:

A queryset containing the root nodes in the tree.

Return type:

NS_NodeQuerySet

classmethod get_region_tree(region_slug: str) NS_NodeQuerySet[source]

Get the tree of a specific region

Parameters:

region_slug (str) – The slug of the requested Region

Returns:

A QuerySet of nodes ordered as DFS, including the parent.

Return type:

NS_NodeQuerySet

get_repr() str[source]

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

Returns:

The canonical string representation of the page

Return type:

str

get_root()[source]
Returns:

the root node for the current node object.

classmethod get_root_nodes()[source]
Returns:

A queryset containing the root nodes in the tree.

classmethod get_root_pages(region_slug: str) PageQuerySet[source]

Gets all root pages

Parameters:

region_slug (str) – Slug defining the region

Returns:

All root pages i.e. pages without parents

Return type:

PageQuerySet

get_siblings()[source]
Returns:

A queryset of all the node’s siblings, including the node itself.

get_sorted_pos_queryset(siblings, newobj)[source]
Returns:

A queryset of the nodes that must be moved to the right. Called only for Node models with node_order_by

This function is based on _insertion_target_filters from django-mptt (BSD licensed) by Jonathan Buchanan: https://github.com/django-mptt/django-mptt/blob/0.3.0/mptt/signals.py

get_translation(language_slug: str) AbstractContentTranslation | None[source]

This function uses the reverse foreign key self.translations to get all translations of self and filters them to the requested Language slug.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

The translation in the requested Language or None 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.

Parameters:

language_slug (str) – The slug of the desired Language

Returns:

A string describing the state of the translation, one of CHOICES

Return type:

str

classmethod get_tree(parent: AbstractTreeNode | None = None) NS_NodeQuerySet[source]

Get the tree of a specific parent node

Parameters:

parent (AbstractTreeNode | None) – The parent node of which the tree should be returned (optional, if no parent is given, all trees are returned.)

Returns:

A QuerySet of nodes ordered as DFS, including the parent.

Return type:

NS_NodeQuerySet

get_tree_max_depth(max_depth: int = 1) NS_NodeQuerySet[source]

Return all descendants with depth less or equal to max depth relative to this nodes depth

Parameters:

max_depth (int) – The nodes maximum depth in the tree

Returns:

This node including its descendants with relative max depth

Return type:

NS_NodeQuerySet

hix_ignore: bool[source]

Type: BooleanField

Ignore HIX value. This allows to ignore HIX value for this specific page.

Whether the HIX value is ignored (this is False by default if not overwritten by a submodel)

icon[source]

Type: ForeignKey to MediaFile

Icon (related name: pages)

icon_id[source]

Internal field, use icon instead.

id[source]

Type: BigAutoField

Primary key: ID

implicitly_archived[source]

This checks whether one of the page’s ancestors is archived which means that this page is implicitly archived as well.

Returns:

Whether or not this page is implicitly archived

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_child_of(node)[source]
Returns:

True if the node is a child of another node given as an argument, else, returns False

Parameters:

node – The node that will be checked as a parent

is_descendant_of(node)[source]
Returns:

True if the node if a descendant of another node given as an argument, else, returns False

is_leaf()[source]
Returns:

True if the node is a leaf node (else, returns False)

is_root()[source]
Returns:

True if the node is a root node (else, returns False)

is_sibling_of(node)[source]
Returns:

True if the node is a sibling of another node given as an argument, else, returns False

Parameters:

node – The node that will be checked as a sibling

languages[source]

This property returns a list of all Language objects, to which a translation exists.

Returns:

The existing languages of this content object

lft[source]

Type: PositiveIntegerField

Lft

classmethod load_bulk(bulk_data, parent=None, keep_ids=False)[source]

Loads a list/dictionary structure to the tree.

mirrored_page[source]

Type: ForeignKey to Page

Mirrored page. If the page embeds live content from another page, it is referenced here. (related name: mirroring_pages)

mirrored_page_first[source]

Type: BooleanField

Position of mirrored page. If a mirrored page is set, this field determines whether the live content is embedded before the content of this page or after.

mirrored_page_id[source]

Internal field, use mirrored_page instead.

mirroring_pages[source]

Type: Reverse ForeignKey from Page

All mirroring pages of this page (related name of mirrored_page)

move(target: Page, pos: str | None = None) None[source]

Moving tree nodes potentially causes changes to the fields tree_id, lft and rgt in NS_Node so the cache of page translations has to be cleared, because of it’s relation to Page

Parameters:
  • target (Page) – The target node which determines the new position

  • pos (str | None) – The new position of the page relative to the target (choices: position)

Raises:

InvalidPosition – If the node is moved to another region

Return type:

None

next_region_sibling[source]

Get the next node’s sibling, or None if it was the rightmost sibling.

Returns:

The next node’s sibling in its region

node_order_by = [][source]
objects = <integreat_cms.cms.models.pages.page.PageManager object>[source]

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

Custom model manager to inherit methods from tree manager as well as the custom content queryset

organization[source]

Type: ForeignKey to Organization

Responsible organization. This allows all members of the organization to edit and publish this page. (related name: pages)

organization_id[source]

Internal field, use organization instead.

parent[source]

Type: ForeignKey to Page

Parent page (related name: children)

parent_id[source]

Internal field, use parent instead.

property pk[source]
prefetched_major_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_major_translations_by_language_slug[source]

This method returns a mapping from language slugs to their major translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_or_draft_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

prefetched_public_translations_by_language_slug[source]

This method returns a mapping from language slugs to their public translations of this object

Returns:

The object translation in the requested Language or None if no translation exists

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

prepare_database_save(field)[source]
prev_region_sibling[source]

Get the previous node’s sibling, or None if it was the leftmost sibling.

Returns:

The previous node’s sibling in its region

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

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 to Region

Region (related name: pages)

region_id[source]

Internal field, use region instead.

region_siblings[source]

Get all siblings of a specific node in its region

Returns:

A QuerySet of all the node’s siblings, including the node itself.

relative_depth[source]

The relative depth inside a cached tree structure. This is relevant for archived pages, where even sub-pages should be displayed as root-pages if their parents are not archived.

Returns:

The relative depth of this node inside its queryset

restore() None[source]

Restores the page and adds all links of this page and its now non-archived subpages back

Return type:

None

rgt[source]

Type: PositiveIntegerField

Rgt

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.

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 from PageTranslation

All translations of this page (related name of page)

tree_id[source]

Type: PositiveIntegerField

Tree id

unique_error_message(model_class, unique_check)[source]
validate_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

class integreat_cms.cms.models.pages.page.PageManager(*args, **kwargs)[source]

Bases: Manager

Custom manager for pages to inherit methods from both managers for tree nodes and content objects

__init__()[source]
aaggregate(*args, **kwargs)[source]
abulk_create(objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None, unique_fields=None)[source]
abulk_update(objs, fields, batch_size=None)[source]
acontains(obj)[source]
acount()[source]
acreate(**kwargs)[source]
aearliest(*fields)[source]
aexists()[source]
aexplain(*, format=None, **options)[source]
afirst()[source]
aget(*args, **kwargs)[source]
aget_or_create(defaults=None, **kwargs)[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.

ain_bulk(id_list=None, *, field_name='pk')[source]
aiterator(chunk_size=2000)[source]

An asynchronous iterator over the results from applying this QuerySet to the database.

alast()[source]
alatest(*fields)[source]
alias(*args, **kwargs)[source]

Return a query set with added aliases for extra data or aggregations.

all()[source]
annotate(*args, **kwargs)[source]

Return a query set in which the returned objects have been annotated with extra data or aggregations.

aupdate(**kwargs)[source]
aupdate_or_create(defaults=None, **kwargs)[source]
auto_created = False[source]
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.

check(**kwargs)[source]
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.

contains(obj)[source]

Return True if the QuerySet contains the provided obj, False otherwise.

contribute_to_class(cls, name)[source]
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.

creation_counter = 46[source]
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’.

property db[source]
db_manager(using=None, hints=None)[source]
deconstruct()[source]

Return a 5-tuple of the form (as_manager (True), manager_class, queryset_class, args, kwargs).

Raise a ValueError if the manager is dynamically generated.

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.

difference(*other_qs)[source]
distinct(*field_names)[source]

Return a new QuerySet instance that will select only distinct results.

earliest(*fields)[source]
exclude(*args, **kwargs)[source]

Return a new QuerySet instance with NOT (args) ANDed to the existing set.

exists()[source]

Return True if the QuerySet would have any results, False otherwise.

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.

first()[source]

Return the first object of a query or None if no match is found.

classmethod from_queryset(queryset_class, class_name=None)[source]
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.

get_queryset() PageQuerySet[source]

Sets the custom queryset as the default.

Returns:

The sorted queryset

Return type:

PageQuerySet

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.

intersection(*other_qs)[source]
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.

last()[source]

Return the last object of a query or None if no match is found.

latest(*fields)[source]

Return the latest object according to fields (if given) or by the model’s Meta.get_latest_by.

none()[source]

Return an empty QuerySet.

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.

order_by(*field_names)[source]

Return a new QuerySet instance with the ordering changed.

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.

raw(raw_query, params=(), translations=None, using=None)[source]
reverse()[source]

Reverse the ordering of the QuerySet.

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.

union(*other_qs, all=False)[source]
update(**kwargs)[source]

Update all elements in the current QuerySet, setting all the given fields to the appropriate values.

update_or_create(defaults=None, **kwargs)[source]

Look up an object with the given kwargs, updating one with defaults if it exists, otherwise create a new one. Return a tuple (object, created), where created is a boolean specifying whether an object was created.

use_in_migrations = False[source]

If set to True the manager will be serialized into migrations and will thus be available in e.g. RunPython operations.

using(alias)[source]

Select which database this QuerySet should execute against.

values(*fields, **expressions)[source]
values_list(*fields, flat=False, named=False)[source]
class integreat_cms.cms.models.pages.page.PageQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: NS_NodeQuerySet, ContentQuerySet

Custom queryset for pages to inherit methods from both querysets for tree nodes and content objects

__init__(model=None, query=None, using=None, hints=None)[source]
async aaggregate(*args, **kwargs)[source]
async abulk_create(objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None, unique_fields=None)[source]
async abulk_update(objs, fields, batch_size=None)[source]
async acontains(obj)[source]
async acount()[source]
async acreate(**kwargs)[source]
async adelete()[source]
async aearliest(*fields)[source]
async aexists()[source]
async aexplain(*, format=None, **options)[source]
async afirst()[source]
async aget(*args, **kwargs)[source]
async aget_or_create(defaults=None, **kwargs)[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 ain_bulk(id_list=None, *, field_name='pk')[source]
async aiterator(chunk_size=2000)[source]

An asynchronous iterator over the results from applying this QuerySet to the database.

async alast()[source]
async alatest(*fields)[source]
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.

classmethod as_manager()[source]
async aupdate(**kwargs)[source]
async aupdate_or_create(defaults=None, **kwargs)[source]
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.

cache_tree(archived: bool | None = None, language_slug: str | None = None) list[Page][source]

Caches a page tree queryset in a python data structure.

Parameters:
  • archived (bool | None) – Whether the pages should be limited to either archived or non-archived pages. If not passed or None, both archived and non-archived pages are returned.

  • language_slug (str | None) – Code to identify the desired language (optional, requires archived to be False)

Raises:

ValueError – Indicates that the combination of parameters is not supported.

Returns:

A list of pages with cached children, descendants and ancestors and a list of all skipped pages

Return type:

list[Page]

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.

contains(obj)[source]

Return True if the QuerySet contains the provided obj, False otherwise.

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’.

property db[source]

Return the database used if this query is executed now.

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.

delete(*args, removed_ranges=None, deleted_counter=None, **kwargs)[source]

Custom delete method, will remove all descendant nodes to ensure a consistent tree (no orphans)

Returns:

tuple of the number of objects deleted and a dictionary with the number of deletions per object type

difference(*other_qs)[source]
distinct(*field_names)[source]

Return a new QuerySet instance that will select only distinct results.

earliest(*fields)[source]
exclude(*args, **kwargs)[source]

Return a new QuerySet instance with NOT (args) ANDed to the existing set.

exists()[source]

Return True if the QuerySet would have any results, False otherwise.

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.

first()[source]

Return the first object of a query or None if no match is found.

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.

intersection(*other_qs)[source]
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.

last()[source]

Return the last object of a query or None if no match is found.

latest(*fields)[source]

Return the latest object according to fields (if given) or by the model’s Meta.get_latest_by.

none()[source]

Return an empty QuerySet.

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.

order_by(*field_names)[source]

Return a new QuerySet instance with the ordering changed.

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:

ContentQuerySet

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:

ContentQuerySet

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:

ContentQuerySet

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:

ContentQuerySet

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 given status

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:

ContentQuerySet

property query[source]
raw(raw_query, params=(), translations=None, using=None)[source]
resolve_expression(*args, **kwargs)[source]
reverse()[source]

Reverse the ordering of the QuerySet.

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.

union(*other_qs, all=False)[source]
update(**kwargs)[source]

Update all elements in the current QuerySet, setting all the given fields to the appropriate values.

update_or_create(defaults=None, **kwargs)[source]

Look up an object with the given kwargs, updating one with defaults if it exists, otherwise create a new one. Return a tuple (object, created), where created is a boolean specifying whether an object was created.

using(alias)[source]

Select which database this QuerySet should execute against.

values(*fields, **expressions)[source]
values_list(*fields, flat=False, named=False)[source]

Page Translation

class integreat_cms.cms.models.pages.page_translation.PageTranslation(*args, **kwargs)[source]

Bases: AbstractBasePageTranslation

Data model representing a page translation

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

  • title (CharField) – Title of the page

  • slug (SlugField) – Page 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) – Content of the page

  • 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.

  • hix_score (FloatField) – HIX score

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

feedback (Reverse ForeignKey from PageFeedback) – All feedback of this page translation (related name of page_translation)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
silent_variable_failure = True[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

__init__(*args, **kwargs)[source]
add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(*args, **kwargs)[source]
async adelete(using=None, keep_parents=False)[source]
all_versions[source]

This property returns all versions of this translation’s page in its language

Returns:

All versions of this translation

ancestor_path[source]

This property calculates the path of all parents of the page

Returns:

The relative path to the page

async arefresh_from_db(using=None, fields=None)[source]
async asave(force_insert=False, force_update=False, using=None, update_fields=None)[source]
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 from self.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

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

Returns:

The url

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

classmethod check(**kwargs)[source]
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.

combined_last_updated[source]

This function combines the last_updated date from this PageTranslation and from a mirrored page. If this translation has no content, then the date from the mirrored translation will be used. In other cases, the date from this translation will be used.

Returns:

The last_updated date of this or the mirrored page translation

combined_text[source]

This function combines the text from this PageTranslation with the text from the mirrored page. Mirrored content always includes the live content from another page. This content needs to be added when delivering content to end users. If the mirrored page is not available in the current language, or if the content is empty, an error message for the user will be used instead.

Returns:

The combined content of this page and the mirrored page

content[source]

Type: TextField

Content of the page

creator[source]

Type: ForeignKey to User

Creator (related name: page_translations)

creator_id[source]

Internal field, use creator instead.

currently_in_translation[source]

Type: BooleanField

Currently in translation. Flag to indicate a translation is being updated by an external translator

date_error_message(lookup_type, field_name, unique_for)[source]
delete(using=None, keep_parents=False)[source]
display_content[source]

This property returns the content that can be displayed to the user. This is just the normal content unless this translation is empty. Then a message will be returned which prompts the user to view the page in another language instead.

Returns:

Html text for the content of this translation

feedback[source]

Type: Reverse ForeignKey from PageFeedback

All feedback of this page translation (related name of page_translation)

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

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

Returns:

The foreign field name

Return type:

Literal[‘page’]

foreign_object[source]

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

Returns:

The page to which the translation belongs

classmethod from_db(db, field_names, values)[source]
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:

str

get_constraints()[source]
classmethod get_current_translations(region: Region, language: Language) QuerySet[PageTranslation][source]

This function is similar to get_translations() but returns only page translations which are currently being translated by an external translator

Parameters:
Returns:

All currently translated translations of a region in a specific language

Return type:

QuerySet[PageTranslation]

get_deferred_fields()[source]

Return a set containing names of deferred fields for this instance.

classmethod get_model_name_plural() str[source]

Get the plural representation of this model name

Returns:

The plural model name

Return type:

str

get_next_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=True, **kwargs)[source]

Finds next instance based on last_updated. See get_next_by_FOO() for more information.

classmethod get_outdated_translations(region: Region, language: Language) QuerySet[PageTranslation][source]

This function is similar to get_translations() but returns only page translations which are outdated

Parameters:
Returns:

All outdated translations of a region in a specific language

Return type:

QuerySet[PageTranslation]

get_previous_by_last_updated(*, field=<django.db.models.DateTimeField: last_updated>, is_next=False, **kwargs)[source]

Finds previous instance based on last_updated. See get_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:

str

get_status_display(*, field=<django.db.models.CharField: status>)[source]

Shows the label of the status. See get_FOO_display() for more information.

classmethod get_translations(region: Region, language: Language) QuerySet[PageTranslation][source]

This function retrieves the most recent versions of a all PageTranslation objects of a Region in a specific Language

Parameters:
Returns:

A QuerySet of all page translations of a region in a specific language

Return type:

QuerySet[PageTranslation]

classmethod get_up_to_date_translations(region: Region, language: Language) QuerySet[PageTranslation][source]

This function is similar to get_translations() but returns only page translations which are up to date

Parameters:
Returns:

All up to date translations of a region in a specific language

Return type:

QuerySet[PageTranslation]

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_score[source]

Type: FloatField

HIX score

The HIX score is None if not overwritten by a submodel

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:

Wether the HIX value is sufficient for MT

id[source]

Type: BigAutoField

Primary key: ID

is_empty[source]

This property returns whether the content of this translation is empty

Returns:

Whether the content of this translation is empty

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 not outdated and not being translated at the moment.

Returns:

Flag which indicates whether a translation is up to date

language[source]

Type: ForeignKey to Language

Language (related name: page_translations)

language_id[source]

Internal field, use language instead.

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

Type: Reverse GenericRelation from PageTranslation

All page 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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

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.

mirrored_translation_text[source]

This method returns the text of the mirrored translation or an empty string, if it is not available in this language

Returns:

The text

mirrored_translation_text_or_fallback_message[source]

This method returns the text of the mirrored translation. If there is no mirrored translation, it returns an empty string. If there is a mirrored page but no translation, a html error message will be returned with languages that are translated as options.

Returns:

The text, as specified

objects = <django.db.models.Manager object>[source]
page[source]

Type: ForeignKey to Page

Page (related name: translations)

page_id[source]

Internal field, use page instead.

path() SafeString[source]

This method returns a human-readable path that should uniquely identify this page translation within a given region

Returns:

The path

Return type:

SafeString

property pk[source]
prepare_database_save(field)[source]
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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

public_source_translation[source]

This property returns the public translation which was used to create the self translation. It derives this information from the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if no public source translation exists)

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

readable_title[source]

Get the title of a page translation including the title in the best translation

Returns:

The readable title of the page translation

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(*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

Parameters:
  • region (Region) –

  • language_slug (str) –

  • query (str) –

Return type:

QuerySet

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.

short_url[source]

This function returns the absolute short url to the page translation

Returns:

The short url of a page translation

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

Page 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 the Region’s root LanguageTreeNode.

Returns:

The content translation in the source Language (None if the translation is in the Region’s default Language)

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

tags[source]

This functions returns a list of translated tags which apply to this function. Supported tags: * Live content: if the page of this translation has live content * Empty: if the page contains no text and has no non-archived subpages

Returns:

A list of tags which apply to this translation

title[source]

Type: CharField

Title of the page

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

unique_error_message(model_class, unique_check)[source]
url_infix[source]

Generates the infix of the url of the page translation object which is the ancestor path of the page

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_constraints(exclude=None)[source]
validate_unique(exclude=None)[source]

Check unique constraints on the model and raise ValidationError if any failed.

version[source]

Type: PositiveIntegerField

Revision