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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_allow_empty()[source]
Return
True
if the view should display empty lists andFalse
if a 404 should be raised instead.
- get_extra_filters() Q [source]
Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions
- Returns:
Q Object to be used as filter argument
- Return type:
Q
- get_paginate_by(queryset)[source]
Get the number of items to paginate by, or
None
for no pagination.
- get_paginate_orphans()[source]
Return the maximum number of orphans extend the last page by when paginating.
- get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]
Return an instance of the paginator for this view.
- get_permission_denied_message()[source]
Override this method to override the permission_denied_message attribute.
- get_permission_required() tuple[str] [source]
Override this method to override the permission_required attribute.
- get_queryset() Any [source]
Get the queryset of selected items for this bulk action
- Raises:
Http404 – HTTP status 404 if no objects with the given ids exist
- Returns:
The QuerySet of the filtered links
- Return type:
Any
- get_redirect_field_name()[source]
Override this method to override the redirect_field_name attribute.
- get_redirect_url(*args: Any, **kwargs: Any) str [source]
Retrieve url for redirection
- Parameters:
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
url to redirect to
- Return type:
- http_method_names: list[str] = ['post'][source]
The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.
- 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.
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_allow_empty()[source]
Return
True
if the view should display empty lists andFalse
if a 404 should be raised instead.
- get_extra_filters() Q [source]
Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions
- Returns:
Q Object to be used as filter argument
- Return type:
Q
- get_paginate_by(queryset)[source]
Get the number of items to paginate by, or
None
for no pagination.
- get_paginate_orphans()[source]
Return the maximum number of orphans extend the last page by when paginating.
- get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]
Return an instance of the paginator for this view.
- get_permission_denied_message()[source]
Override this method to override the permission_denied_message attribute.
- get_permission_required() tuple[str] [source]
Override this method to override the permission_required attribute.
- get_queryset() Any [source]
Get the queryset of selected items for this bulk action
- Raises:
Http404 – HTTP status 404 if no objects with the given ids exist
- Returns:
The QuerySet of the filtered links
- Return type:
Any
- get_redirect_field_name()[source]
Override this method to override the redirect_field_name attribute.
- get_redirect_url(*args: Any, **kwargs: Any) str [source]
Retrieve url for redirection
- Parameters:
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
url to redirect to
- Return type:
- http_method_names: list[str] = ['post'][source]
The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_allow_empty()[source]
Return
True
if the view should display empty lists andFalse
if a 404 should be raised instead.
- get_extra_filters() Q [source]
Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions
- Returns:
Q Object to be used as filter argument
- Return type:
Q
- get_paginate_by(queryset)[source]
Get the number of items to paginate by, or
None
for no pagination.
- get_paginate_orphans()[source]
Return the maximum number of orphans extend the last page by when paginating.
- get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]
Return an instance of the paginator for this view.
- get_permission_denied_message()[source]
Override this method to override the permission_denied_message attribute.
- get_permission_required() tuple[str] [source]
Override this method to override the permission_required attribute.
- get_queryset() Any [source]
Get the queryset of selected items for this bulk action
- Raises:
Http404 – HTTP status 404 if no objects with the given ids exist
- Returns:
The QuerySet of the filtered links
- Return type:
Any
- get_redirect_field_name()[source]
Override this method to override the redirect_field_name attribute.
- get_redirect_url(*args: Any, **kwargs: Any) str [source]
Retrieve url for redirection
- Parameters:
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
url to redirect to
- Return type:
- http_method_names: list[str] = ['post'][source]
The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get_allow_empty()[source]
Return
True
if the view should display empty lists andFalse
if a 404 should be raised instead.
- get_extra_filters() Q [source]
Get extra filters for get_queryset(). Overwrite this method to specify needed filters e.g. as in ~integreat_cms.cms.views.contact.contact_bulk_actions
- Returns:
Q Object to be used as filter argument
- Return type:
Q
- get_paginate_by(queryset)[source]
Get the number of items to paginate by, or
None
for no pagination.
- get_paginate_orphans()[source]
Return the maximum number of orphans extend the last page by when paginating.
- get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]
Return an instance of the paginator for this view.
- get_permission_denied_message()[source]
Override this method to override the permission_denied_message attribute.
- get_permission_required() tuple[str] [source]
Override this method to override the permission_required attribute.
- get_queryset() Any [source]
Get the queryset of selected items for this bulk action
- Raises:
Http404 – HTTP status 404 if no objects with the given ids exist
- Returns:
The QuerySet of the filtered links
- Return type:
Any
- get_redirect_field_name()[source]
Override this method to override the redirect_field_name attribute.
- get_redirect_url(*args: Any, **kwargs: Any) str [source]
Retrieve url for redirection
- Parameters:
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
url to redirect to
- Return type:
- http_method_names: list[str] = ['post'][source]
The list of HTTP method names that this view will accept. The bulk action form uses only POST as submission method.
- 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
- get_allow_empty()[source]
Return
True
if the view should display empty lists andFalse
if a 404 should be raised instead.
- get_paginate_by(queryset)[source]
Get the number of items to paginate by, or
None
for no pagination.
- get_paginate_orphans()[source]
Return the maximum number of orphans extend the last page by when paginating.
- get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]
Return an instance of the paginator for this view.
- get_queryset()[source]
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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
- get_context_data(**kwargs: Any) dict[str, Any] [source]
Returns a dictionary representing the template context (see
get_context_data()
).
- 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.
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- 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
- render_to_response(context, **response_kwargs)[source]
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- response_class[source]
alias of
TemplateResponse
- 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
- 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:
- revoke_permission(user: User, page: Page) PermissionMessage [source]
Revoke the permission
- Parameters:
- Returns:
Response message
- Return type:
- revoke_with_no_effect_success_message = 'Information: The user "{}" has been removed from the authors of this page, but has the implicit permission to edit this page anyway.'[source]
- 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
- capitalize()[source]
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
- center(width, fillchar=' ', /)[source]
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
- count(sub[, start[, end]]) int [source]
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
- encode(encoding='utf-8', errors='strict')[source]
Encode the string using the codec registered for encoding.
- encoding
The encoding in which to encode the string.
- errors
The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
- endswith(suffix[, start[, end]]) bool [source]
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
- expandtabs(tabsize=8)[source]
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(sub[, start[, end]]) int [source]
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- format(*args, **kwargs) str [source]
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).
- format_map(mapping) str [source]
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).
- index(sub[, start[, end]]) int [source]
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- isalnum()[source]
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
- isalpha()[source]
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
- isascii()[source]
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
- isdecimal()[source]
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
- isdigit()[source]
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
- isidentifier()[source]
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.
- islower()[source]
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
- isnumeric()[source]
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
- isprintable()[source]
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
- isspace()[source]
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
- istitle()[source]
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
- isupper()[source]
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
- join(iterable, /)[source]
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
- ljust(width, fillchar=' ', /)[source]
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
- lstrip(chars=None, /)[source]
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
- static maketrans()[source]
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
- partition(sep, /)[source]
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
- removeprefix(prefix, /)[source]
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
- removesuffix(suffix, /)[source]
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
- replace(old, new, count=-1, /)[source]
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
- rfind(sub[, start[, end]]) int [source]
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(sub[, start[, end]]) int [source]
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- rjust(width, fillchar=' ', /)[source]
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
- rpartition(sep, /)[source]
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
- rsplit(sep=None, maxsplit=-1)[source]
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits (starting from the left). -1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
- rstrip(chars=None, /)[source]
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- split(sep=None, maxsplit=-1)[source]
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits (starting from the left). -1 (the default value) means no limit.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
- splitlines(keepends=False)[source]
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
- startswith(prefix[, start[, end]]) bool [source]
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
- strip(chars=None, /)[source]
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- swapcase()[source]
Convert uppercase characters to lowercase and lowercase characters to uppercase.
- title()[source]
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
- translate(table, /)[source]
Replace each character in the string using the given translation table.
- table
Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
- 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
- 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:
- revoke_permission(user: User, page: Page) PermissionMessage [source]
Revoke the permission
- Parameters:
- Returns:
Response message
- Return type:
- revoke_with_no_effect_success_message = 'Information: The user "{}" has been removed from the editors of this page, but has the implicit permission to publish this page anyway.'[source]
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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
- get_context_data(**kwargs: Any) dict[str, Any] [source]
Returns a dictionary representing the template context (see
get_context_data()
).
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- 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
- render_to_response(context, **response_kwargs)[source]
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- response_class[source]
alias of
TemplateResponse
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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
- get_context_data(**kwargs: Any) dict[str, Any] [source]
Returns a dictionary representing the template context (see
get_context_data()
).
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- render_to_response(context, **response_kwargs)[source]
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- response_class[source]
alias of
TemplateResponse
- 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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- back_to_form_label: Promise = 'Back to the page form'[source]
The label of the “back to form” button
- dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect | TemplateResponse [source]
Validate the versions view
- 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 | TemplateResponse
- get_context_data(**kwargs: Any) dict[str, Any] [source]
Returns a dictionary representing the template context (see
get_context_data()
).
- get_object(queryset=None)[source]
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- get_permission_denied_message()[source]
Override this method to override the permission_denied_message attribute.
- get_permission_required()[source]
Override this method to override the permission_required attribute. Must return an iterable.
- get_queryset()[source]
Filter the content objects by the current region
- Raises:
Http404 – HTTP status 404 if the content is not found
- Returns:
The rendered template response
- Return type:
- get_redirect_field_name()[source]
Override this method to override the redirect_field_name attribute.
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- has_change_permission() bool [source]
Whether the user has the permission to change objects
- Returns:
Whether the user can change objects
- Return type:
- has_permission() bool [source]
Override
django.contrib.auth.mixins.PermissionRequiredMixin.has_permission()
- Returns:
Whether the current user can access this view
- 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:
- has_view_permission() bool [source]
Whether the user has the permission to change objects
- Returns:
Whether the user can change 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
- object: AbstractContentModel | None = None[source]
The current content object (see
SingleObjectMixin
)
- property pk_url_kwarg: str[source]
The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is ‘pk’. See
django.views.generic.detail.SingleObjectMixin.pk_url_kwarg
.- Returns:
The name of URL kwarg of the id
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Restore a previous revision of a page translation
- 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
- render_to_response(context, **response_kwargs)[source]
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- response_class[source]
alias of
TemplateResponse
- restore_version(restored_version: Any) None [source]
Restore the given version
- Parameters:
restored_version (Any) – The version which should be restored
- Return type:
None
- selected_version: AbstractContentTranslation | None = None[source]
The currently selected translation version
- template_name: str = 'content_versions.html'[source]
The template to render (see
TemplateResponseMixin
)
- translations: list[AbstractContentTranslation] = [][source]
All translations of the content object in the current language
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
- __init__(**kwargs)[source]
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- 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()
).
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- 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
- render_to_response(context, **response_kwargs)[source]
Return a response, using the response_class for this view, with a template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
- response_class[source]
alias of
TemplateResponse