Pages
This package contains page-related data models:
Page
andPageTranslation
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
toRegion
) – 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 (seearchived()
).- 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 (TruncatingCharField) – 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:
language (
ForeignKey
toLanguage
) – Languagecreator (
ForeignKey
toUser
) – Creator
- 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
Imprint Page
- class integreat_cms.cms.models.pages.imprint_page.ImprintPage(*args, **kwargs)[source]
Bases:
AbstractContentModel
Data model representing an imprint.
- Parameters:
id (BigAutoField) – Primary key: ID
created_date (DateTimeField) – Creation date
Relationship fields:
- Parameters:
region (
ForeignKey
toRegion
) – Region (related name:imprints
)
Reverse relationships:
- Parameters:
translations (Reverse
ForeignKey
fromImprintPageTranslation
) – All translations of this imprint (related name ofpage
)
- 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 (TruncatingCharField) – 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:
language (
ForeignKey
toLanguage
) – Language (related name:imprint_translations
)creator (
ForeignKey
toUser
) – Creator (related name:imprint_translations
)page (
ForeignKey
toImprintPage
) – Imprint (related name:translations
)links (
GenericRelation
toLink
) – Links (related name:imprint_translation
)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- backend_edit_link[source]
This function returns the absolute url to the editor for this translation
- Returns:
The url
- 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:
id (BigAutoField) – Primary key: ID
created_date (DateTimeField) – Creation date
lft (PositiveIntegerField) – Lft
rgt (PositiveIntegerField) – Rgt
tree_id (PositiveIntegerField) – Tree id
depth (PositiveIntegerField) – Depth
explicitly_archived (BooleanField) – Explicitly archived. Whether or not the page is explicitly archived
mirrored_page_first (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.
api_token (CharField) – API access token. API token to allow writing content to translations.
hix_ignore (BooleanField) – Ignore HIX value. This allows to ignore HIX value for this specific page.
Relationship fields:
- Parameters:
parent (
ForeignKey
toPage
) – Parent page (related name:children
)region (
ForeignKey
toRegion
) – Region (related name:pages
)icon (
ForeignKey
toMediaFile
) – Icon (related name:pages
)mirrored_page (
ForeignKey
toPage
) – Mirrored page. If the page embeds live content from another page, it is referenced here. (related name:mirroring_pages
)organization (
ForeignKey
toOrganization
) – Responsible organization. This allows all members of the organization to edit and publish this page. (related name:pages
)authors (
ManyToManyField
toUser
) – 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
toUser
) – 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
toOfferTemplate
) – Page based offer. Select an offer provider whose offers should be displayed on this page. (related name:pages
)
Reverse relationships:
- Parameters:
translations (Reverse
ForeignKey
fromPageTranslation
) – All translations of this page (related name ofpage
)children (Reverse
ForeignKey
fromPage
) – All children of this page (related name ofparent
)mirroring_pages (Reverse
ForeignKey
fromPage
) – All mirroring pages of this page (related name ofmirrored_page
)
- 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.
- 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:
- classmethod get_root_pages(region_slug: str) QuerySet [source]
Gets all root pages
- Parameters:
region_slug (str) – Slug defining the region
- Returns:
All root pages i.e. pages without parents
- Return type:
QuerySet
- 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 toPage
- Parameters:
- 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
- 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:
- 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:
- 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:
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 (TruncatingCharField) – 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
hix_feedback (JSONField) – HIX feedback
Relationship fields:
- Parameters:
language (
ForeignKey
toLanguage
) – Language (related name:page_translations
)creator (
ForeignKey
toUser
) – Creator (related name:page_translations
)page (
ForeignKey
toPage
) – Page (related name:translations
)links (
GenericRelation
toLink
) – Links (related name:page_translation
)
Reverse relationships:
- Parameters:
feedback (Reverse
ForeignKey
fromPageFeedback
) – All feedback of this page translation (related name ofpage_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) list[PageTranslation] [source]
This function is similar to
get_translations()
but returns only page translations which are currently being translated by an external translator
- classmethod get_outdated_translations(region: Region, language: Language) list[PageTranslation] [source]
This function is similar to
get_translations()
but returns only page translations which are outdated
- classmethod get_translations(region: Region, language: Language) QuerySet[PageTranslation] [source]
This function retrieves the most recent versions of all
PageTranslation
objects of aRegion
in a specificLanguage
- classmethod get_up_to_date_translations(region: Region, language: Language) list[PageTranslation] [source]
This function is similar to
get_translations()
but returns only page translations which are up to date
- 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