Pages
This package contains all views related to pages
Page Actions
This module contains view actions related to pages.
- integreat_cms.cms.views.pages.page_actions.archive_page(request: HttpRequest, page_id: int, region_slug: str, language_slug: str) HttpResponseRedirect [source]
Archive page object
- Parameters:
- Raises:
PermissionDenied – If user does not have the permission to edit the specific page
- Returns:
A redirection to the
PageTreeView
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.cancel_translation_process_ajax(request: HttpRequest, region_slug: str, language_slug: str, page_id: int) JsonResponse [source]
This view is called for manually unsetting the translation process
- integreat_cms.cms.views.pages.page_actions.delete_page(request: HttpRequest, page_id: int, region_slug: str, language_slug: str) HttpResponseRedirect [source]
Delete page object
- Parameters:
- Returns:
A redirection to the
PageTreeView
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.expand_page_translation_id(request: HttpRequest, short_url_id: int) HttpResponseRedirect [source]
Searches for a page translation with corresponding ID and redirects browser to web app
- Parameters:
request (HttpRequest) – The current request
short_url_id (int) – The id of the requested page
- Returns:
A redirection to
WEBAPP_URL
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.get_page_content_ajax(request: HttpRequest, region_slug: str, language_slug: str, page_id: int) JsonResponse [source]
Get content of a page translation based on language slug
- Parameters:
- Raises:
Http404 – HTTP status 404 if page translation does not exist
- Returns:
Page translation content as a JSON.
- Return type:
JsonResponse
- integreat_cms.cms.views.pages.page_actions.get_page_order_table_ajax(request: HttpRequest, region_slug: str, parent_id: int | None = None, page_id: int | None = None) HttpResponse [source]
Retrieve the order table for a given page and a given parent page. This is used in the page form to change the order of a page relative to its siblings.
- Parameters:
- Returns:
The rendered page order table
- Return type:
HttpResponse
- integreat_cms.cms.views.pages.page_actions.move_page(request: HttpRequest, region_slug: str, language_slug: str, page_id: int, target_id: int, position: str) HttpResponseRedirect [source]
Move a page object in the page tree
- Parameters:
request (HttpRequest) – The current request
region_slug (str) – The slug of the current region
language_slug (str) – The slug of the current language
page_id (int) – The id of the page which should be moved
target_id (int) – The id of the page which determines the new position
position (str) – The new position of the page relative to the target (choices:
position
)
- Returns:
A redirection to the
PageTreeView
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.preview_page_ajax(request: HttpRequest, page_id: int, region_slug: str, language_slug: str) JsonResponse [source]
Preview page object
- Parameters:
- Raises:
Http404 – HTTP status 404 if page translation does not exist
- Returns:
Significant page data as a JSON.
- Return type:
JsonResponse
- integreat_cms.cms.views.pages.page_actions.refresh_date(request: HttpRequest, page_id: int, region_slug: str, language_slug: str) HttpResponseRedirect [source]
Refresh the date for up-to-date translations of a corresponding page
- Parameters:
- Raises:
PermissionDenied – If the user does not have the permission to refresh page dates
- Returns:
A redirection to the
PageFormView
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.render_mirrored_page_field(request: HttpRequest, region_slug: str, language_slug: str) HttpResponse [source]
Retrieve the rendered mirrored page field template
- integreat_cms.cms.views.pages.page_actions.restore_page(request: HttpRequest, page_id: int, region_slug: str, language_slug: str) HttpResponseRedirect [source]
Restore page object (set
archived=False
)- Parameters:
- Raises:
PermissionDenied – If user does not have the permission to edit the specific page
- Returns:
A redirection to the
PageTreeView
- Return type:
HttpResponseRedirect
- integreat_cms.cms.views.pages.page_actions.upload_xliff(request: HttpRequest, region_slug: str, language_slug: str) HttpResponseRedirect [source]
Upload and import an XLIFF file
- Parameters:
- Returns:
A redirection to the
PageTreeView
- Return type:
HttpResponseRedirect
Page Bulk Actions
- class integreat_cms.cms.views.pages.page_bulk_actions.CancelTranslationProcess(**kwargs)[source]
Bases:
PageBulkActionMixin
,BulkActionView
Bulk action to cancel translation process
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Function to cancel the translation process for multiple pages of the current language at once
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The redirect
- Return type:
HttpResponse
- class integreat_cms.cms.views.pages.page_bulk_actions.ExportMultiLanguageXliffView(**kwargs)[source]
Bases:
PageBulkActionMixin
,BulkActionView
Bulk action for generating XLIFF files for translations in multiple languages.
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Function for handling a XLIFF export request for pages and multiple languages. The pages get extracted from request.GET attribute and the request is forwarded to
pages_to_xliff_file()
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The redirect
- Return type:
HttpResponse
- class integreat_cms.cms.views.pages.page_bulk_actions.ExportXliffView(**kwargs)[source]
Bases:
PageBulkActionMixin
,BulkActionView
Bulk action for generating XLIFF files for translations
- only_public = False[source]
Whether only public translation should be exported
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Function for handling a XLIFF export request for pages. The pages get extracted from request.GET attribute and the request is forwarded to
pages_to_xliff_file()
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The redirect
- Return type:
HttpResponseRedirect
- class integreat_cms.cms.views.pages.page_bulk_actions.GeneratePdfView(**kwargs)[source]
Bases:
PageBulkActionMixin
,BulkActionView
Bulk action for generating a PDF document of the content
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Apply the bulk action on every item in the queryset and redirect
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The redirect
- Return type:
HttpResponseRedirect
- class integreat_cms.cms.views.pages.page_bulk_actions.PageBulkActionMixin[source]
Bases:
MultipleObjectMixin
Mixin for page bulk actions
- model[source]
The model of this
BulkActionView
- 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
)
alias of
Page
Page Context Mixin
- class integreat_cms.cms.views.pages.page_context_mixin.PageContextMixin[source]
Bases:
ContextMixin
This mixin provides extra context for page views
Page Form View
- class integreat_cms.cms.views.pages.page_form_view.PageFormView(**kwargs)[source]
Bases:
TemplateView
,PageContextMixin
,MediaContextMixin
,ContentEditLockMixin
View for the page form and page translation form
- back_url_name: str | None = 'pages'[source]
The url name of the view to show if the user decides to go back (see
ContentEditLockMixin
)
- extra_context = {'current_menu_item': 'new_page'}[source]
The context dict passed to the template (see
ContextMixin
)
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Render
PageForm
andPageTranslationForm
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Raises:
PermissionDenied – If user does not have the permission to edit the specific page
- Returns:
The rendered template response
- Return type:
HttpResponse
- static get_side_by_side_language_options(region: Region, language: Language, page: Page | None) list[dict[str, Any]] [source]
This is a helper function to generate the side-by-side language options for both the get and post requests.
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Submit
PageForm
andPageTranslationForm
and savePage
andPageTranslation
objects. Forms containing images/files need to be additionally instantiated with the FILES attribute of request objects, see File Uploads- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Raises:
PermissionDenied – If user does not have the permission to edit the specific page
- Returns:
The rendered template response
- Return type:
HttpResponseRedirect
- template_name = 'pages/page_form.html'[source]
The template to render (see
TemplateResponseMixin
)
Page Permission Actions
- class integreat_cms.cms.views.pages.page_permission_actions.AbstractPagePermission(permission: str)[source]
Bases:
ABC
An abstract class to handle page permissions
- Parameters:
permission (str)
- build_grant_message(user: User, page: Page) PermissionMessage [source]
Build the success message when granting a permission
- Parameters:
- Returns:
message with level_tag
- Return type:
- build_revoke_message(user: User, page: Page) PermissionMessage [source]
Build the response message after revoking
- Parameters:
- Returns:
permission message
- Return type:
- grant_permission(user: User, page: Page) PermissionMessage [source]
Grant the permission
- Parameters:
- Returns:
Response message
- Return type:
- abstract property grant_success_message: str[source]
Success message for granting a permission
- Returns:
success message
- revoke_permission(user: User, page: Page) PermissionMessage [source]
Revoke the permission
- Parameters:
- Returns:
Response message
- Return type:
- abstract property revoke_success_message: str[source]
Success message for revoking a permission
- Returns:
success message
- abstract property revoke_with_no_effect_success_message: str[source]
Success message for granting a permission without effect
- Returns:
success message
- class integreat_cms.cms.views.pages.page_permission_actions.EditPagePermission[source]
Bases:
AbstractPagePermission
Implementation of AbstractPagePermission for editing page permissions
- class integreat_cms.cms.views.pages.page_permission_actions.MessageLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
StrEnum
Enum for different level tags of a message
- class integreat_cms.cms.views.pages.page_permission_actions.PermissionMessage(message: str, level_tag: MessageLevel)[source]
Bases:
object
Saves message and level_tag of the return message
- Parameters:
message (str)
level_tag (MessageLevel)
- __init__(message: str, level_tag: MessageLevel)[source]
- Parameters:
message (str)
level_tag (MessageLevel)
- class integreat_cms.cms.views.pages.page_permission_actions.PublishPagePermission[source]
Bases:
AbstractPagePermission
Implementation of AbstractPagePermission for publishing page permissions
- integreat_cms.cms.views.pages.page_permission_actions.ensure_page_specific_permissions_enabled(region: Region) None [source]
Ensure the page permission is enabled
- Parameters:
region (Region) – The region the page permission should be enabled for
- Raises:
PermissionDenied – If page permissions are disabled for this region
- Return type:
None
- integreat_cms.cms.views.pages.page_permission_actions.ensure_user_has_correct_permissions(request: HttpRequest, page: Page, user: User) None [source]
Ensure the user has correct permissions
- Parameters:
- Raises:
PermissionDenied – If the user does not have the permission to grant page permissions
- Return type:
None
- integreat_cms.cms.views.pages.page_permission_actions.get_permission(data: Any) AbstractPagePermission [source]
Gets the Permission object for the requested permission
- Parameters:
data (Any) – Request data
- Raises:
PermissionDenied – If unknown page permissions should be changed
- Returns:
Permission object
- Return type:
- integreat_cms.cms.views.pages.page_permission_actions.grant_page_permission_ajax(request: HttpRequest, region_slug: str) HttpResponse [source]
Grant a user editing or publishing permissions on a specific page object
- Parameters:
request (HttpRequest) – The current request
region_slug (str) – The slug of the current region
- Raises:
PermissionDenied – If page permissions are disabled for this region or the user does not have the permission to grant page permissions
- Returns:
The rendered page permission table
- Return type:
HttpResponse
- integreat_cms.cms.views.pages.page_permission_actions.log_permission_request(request: HttpRequest, user: User, permission: AbstractPagePermission, page: Page, grant: bool) None [source]
Logging for page permission request
- Parameters:
request (HttpRequest) – Request
user (User) – user that should be granted or revoked a permission
permission (AbstractPagePermission) – permission that should be granted or revoked
page (Page) – page for which the permission should be granted or revoked
grant (bool) – if the permission is granted or revoked
- Return type:
None
- integreat_cms.cms.views.pages.page_permission_actions.revoke_page_permission_ajax(request: HttpRequest, region_slug: str) HttpResponse [source]
Remove a page permission for a given user and page
- Parameters:
request (HttpRequest) – The current request
region_slug (str) – The slug of the current region
- Raises:
PermissionDenied – If page permissions are disabled for this region or the user does not have the permission to revoke page permissions
- Returns:
The rendered page permission table
- Return type:
HttpResponse
Page Sbs View
- class integreat_cms.cms.views.pages.page_sbs_view.PageSideBySideView(**kwargs)[source]
Bases:
TemplateView
,PageContextMixin
,MediaContextMixin
,ContentEditLockMixin
View for the page side by side form
- back_url_name: str | None = 'pages'[source]
The url name of the view to show if the user decides to go back (see
ContentEditLockMixin
)
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse | HttpResponseRedirect [source]
Render
PageTranslationForm
on the side by side view- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse | HttpResponseRedirect
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Submit
PageTranslationForm
and savePageTranslation
object- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Raises:
PermissionDenied – If user does not have the permission to edit pages
- Returns:
The rendered template response
- Return type:
HttpResponse
- template_name = 'pages/page_sbs.html'[source]
The template to render (see
TemplateResponseMixin
)
- integreat_cms.cms.views.pages.page_sbs_view.get_old_source_content(page: Page, source_language: Language, target_language: Language) str [source]
This function returns the content of the source language translation that was up to date when the latest (no minor edit) target language translation was created.
Page Tree View
- class integreat_cms.cms.views.pages.page_tree_view.PageTreeView(**kwargs)[source]
Bases:
TemplateView
,PageContextMixin
,MachineTranslationContextMixin
View for showing the page tree
- archived = False[source]
Whether or not to show archived pages
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Render page tree
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse
- template = 'pages/page_tree.html'[source]
Template for list of non-archived pages
- template_archived = 'pages/page_tree_archived.html'[source]
Template for list of archived pages
- property template_name: str[source]
Select correct HTML template, depending on
archived
flag (seeTemplateResponseMixin
)- Returns:
Path to HTML template
- translation_model[source]
The translation model of this list view (used to determine whether machine translations are permitted)
- 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
)
alias of
PageTranslation
Page Version View
- class integreat_cms.cms.views.pages.page_version_view.PageVersionView(**kwargs)[source]
Bases:
PageContextMixin
,ContentVersionView
View for browsing the page versions and restoring old page versions
- back_to_form_label: Promise = 'Back to the page form'[source]
The label of the “back to form” button
- has_change_permission() bool [source]
Whether the user has the permission to change objects
- Returns:
Whether the user can change objects
- Return type:
- has_publish_permission() bool [source]
Whether the user has the permission to publish objects
- Returns:
Whether the user can publish objects
- Return type:
- model[source]
The current content model (see
SingleObjectMixin
)- 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
)
alias of
Page
Page XLIFF Import View
- class integreat_cms.cms.views.pages.page_xliff_import_view.PageXliffImportView(**kwargs)[source]
Bases:
TemplateView
,PageContextMixin
View for importing uploaded XLIFF files
- dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse [source]
Redirect to page tree if XLIFF directory does not exist
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponse
- get_context_data(**kwargs: Any) dict[str, Any] [source]
Returns a dictionary representing the template context (see
get_context_data()
).
- language = None[source]
The language of this view
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Confirm the xliff import
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The rendered template response
- Return type:
HttpResponseRedirect
- region = None[source]
The region of this view
- template_name = 'pages/page_xliff_import_view.html'[source]
Template for XLIFF import view
- xliff_dir = None[source]
The upload directory of this import