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

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

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:
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

page[source]

The page the translation belongs to

To be implemented in the inheriting model

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

short_url[source]

This property calculates the short url dynamically

To be implemented in the inheriting model

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

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

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

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

static get_translation_model() ModelBase[source]

Returns the translation model of this content model

Returns:

The class of translations

Return type:

ModelBase

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

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

backend_edit_link[source]

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

Returns:

The url

short_url[source]

This function returns the absolute short url to the imprint translation

Returns:

The short url of an imprint translation

property slug: str[source]

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

Returns:

pseudo slug for the imprint translation

status[source]

Type: CharField

Status

Choices:

  • DRAFT

  • REVIEW

  • PUBLIC

  • AUTO_SAVE

Manage choices in status

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

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

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

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

explicitly_archived_ancestors[source]

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

Returns:

The list of archived ancestors

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

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_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

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

static get_translation_model() ModelBase[source]

Returns the translation model of this content model

Returns:

The class of translations

Return type:

ModelBase

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)

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

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

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

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

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

get_queryset() PageQuerySet[source]

Sets the custom queryset as the default.

Returns:

The sorted queryset

Return type:

PageQuerySet

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

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]

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

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

ancestor_path[source]

This property calculates the path of all parents of the page

Returns:

The relative path to the page

backend_edit_link[source]

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

Returns:

The url

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

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

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]

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]

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

Type: FloatField

HIX score

The HIX score is None if not overwritten by a submodel

is_empty[source]

This property returns whether the content of this translation is empty

Returns:

Whether the content of this translation is empty

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

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

short_url[source]

This function returns the absolute short url to the page translation

Returns:

The short url of a page translation

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

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