Language Tree
This package contains all views related to the language tree of a region
Language Tree Actions
This module contains view actions for the language tree. Typically, they do not render a whole page, but only parts of it or they redirect to regular views.
- integreat_cms.cms.views.language_tree.language_tree_actions.delete_language_tree_node(request: HttpRequest, region_slug: str, pk: int) HttpResponseRedirect [source]
Deletes the language node of distinct region and all page translations for this language
- integreat_cms.cms.views.language_tree.language_tree_actions.manually_invalidate_models(region: Region) None [source]
This is a helper function to iterate through all affected objects and invalidate their cache. This is necessary as the original cache invalidation of cacheops only triggers for direct foreign key relationships.
- Parameters:
region (Region) – The affected region
- Return type:
None
- integreat_cms.cms.views.language_tree.language_tree_actions.move_language_tree_node(request: HttpRequest, region_slug: str, pk: int, target_id: int, target_position: str) HttpResponseRedirect [source]
This action moves the given language tree node to the given position relative to the given target.
- Parameters:
request (HttpRequest) – The current request
region_slug (str) – The slug of the region which language tree should be modified
pk (int) – The id of the language tree node which should be moved
target_id (int) – The id of the target language tree node
target_position (str) – The desired position (choices:
position
)
- Returns:
A redirection to the language tree
- Return type:
HttpResponseRedirect
Language Tree Bulk Actions
- class integreat_cms.cms.views.language_tree.language_tree_bulk_actions.BulkActivateView(**kwargs)[source]
Bases:
LanguageTreeBulkActionView
Bulk action for activating multiple language tree nodes at once
- action = 'activated'[source]
The name of the action
- field_name = 'active'[source]
The name of the archived-field
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Execute bulk action for language tree node and flush the cache
- 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.language_tree.language_tree_bulk_actions.BulkDisableView(**kwargs)[source]
Bases:
BulkActivateView
Bulk action for disabling multiple language tree nodes at once
- action = 'disabled'[source]
The name of the action
- class integreat_cms.cms.views.language_tree.language_tree_bulk_actions.BulkHideView(**kwargs)[source]
Bases:
BulkMakeVisibleView
Bulk action for hiding multiple language tree nodes at once
- action = 'hidden'[source]
The name of the action
- class integreat_cms.cms.views.language_tree.language_tree_bulk_actions.BulkMakeVisibleView(**kwargs)[source]
Bases:
LanguageTreeBulkActionView
Bulk action for making multiple language tree nodes visible at once
- action = 'made visible'[source]
The name of the action
- field_name = 'visible'[source]
The name of the archived-field
- class integreat_cms.cms.views.language_tree.language_tree_bulk_actions.LanguageTreeBulkActionView(**kwargs)[source]
Bases:
BulkUpdateBooleanFieldView
Bulk action view for language tree nodes which flushes the cache for all content models after each operation
- property action: str[source]
Called when the bulk action is performed and the
action
attribute was not overwritten- Raises:
NotImplementedError – If the
action
attribute is not implemented in the subclass
- property field_name: str[source]
Called when the bulk action is performed and the
field_name
attribute was not overwritten- Raises:
NotImplementedError – If the
field_name
attribute is not implemented in the subclass
- model[source]
The model of this
BulkActionView
- Parameters:
id (BigAutoField) – Primary key: ID
lft (PositiveIntegerField) – Lft
rgt (PositiveIntegerField) – Rgt
tree_id (PositiveIntegerField) – Tree id
depth (PositiveIntegerField) – Depth
visible (BooleanField) – Visible. Defines whether the language is displayed to the users of the app
active (BooleanField) – Active. Defined if content in this language can be created or edited
created_date (DateTimeField) – Creation date
last_updated (DateTimeField) – Modification date
machine_translation_enabled (BooleanField) – Machine translatable. Enable or disable machine translations into this language
preferred_mt_provider (CharField) – Machine translation provider. Preferred provider for translations into this language
Relationship fields:
- Parameters:
parent (
ForeignKey
toLanguageTreeNode
) – Source language (related name:children
)region (
ForeignKey
toRegion
) – Region (related name:language_tree_nodes
)language (
ForeignKey
toLanguage
) – Language (related name:language_tree_nodes
)
Reverse relationships:
- Parameters:
children (Reverse
ForeignKey
fromLanguageTreeNode
) – All children of this language tree node (related name ofparent
)
alias of
LanguageTreeNode
- post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponseRedirect [source]
Execute bulk action for language tree node and flush the cache
- Parameters:
request (HttpRequest) – The current request
*args (Any) – The supplied arguments
**kwargs (Any) – The supplied keyword arguments
- Returns:
The redirect
- Return type:
HttpResponseRedirect
Language Tree Context Mixin
- class integreat_cms.cms.views.language_tree.language_tree_context_mixin.LanguageTreeContextMixin[source]
Bases:
ContextMixin
This mixin provides extra context for language tree views
Language Tree Node Form View
- class integreat_cms.cms.views.language_tree.language_tree_node_form_view.LanguageTreeNodeCreateView(**kwargs)[source]
Bases:
CustomCreateView
Class that handles creating language tree nodes. This view is available within regions.
- form_class[source]
The form class of this form view
Form fields:
language
: Language (ModelChoiceField
)visible
: Visible (BooleanField
)active
: Active (BooleanField
)parent
: Source language (ModelChoiceField
)machine_translation_enabled
: Machine translatable (BooleanField
)_position
: Position (ChoiceField
)_ref_node_id
: Relative to (ChoiceField
)
alias of
LanguageTreeNodeForm
- class integreat_cms.cms.views.language_tree.language_tree_node_form_view.LanguageTreeNodeUpdateView(**kwargs)[source]
Bases:
CustomUpdateView
Class that handles activating/deactivating of a language tree node
- form_valid(form: LanguageTreeNodeForm) HttpResponseRedirect [source]
Saves the form instance, sets the current object for the view, and redirects to
get_success_url()
.- Parameters:
form (LanguageTreeNodeForm) – The valid form instance
- Returns:
A redirection to the success url
- Return type:
HttpResponseRedirect
Language Tree View
- class integreat_cms.cms.views.language_tree.language_tree_view.LanguageTreeView(**kwargs)[source]
Bases:
LanguageTreeContextMixin
,ModelListView
View for rendering the language tree view. This view is available in regions.
- get_queryset() list[LanguageTreeNode] [source]
Get language tree queryset
- Returns:
The language tree of the current region
- Return type:
- model[source]
The model of this list view
- Parameters:
id (BigAutoField) – Primary key: ID
lft (PositiveIntegerField) – Lft
rgt (PositiveIntegerField) – Rgt
tree_id (PositiveIntegerField) – Tree id
depth (PositiveIntegerField) – Depth
visible (BooleanField) – Visible. Defines whether the language is displayed to the users of the app
active (BooleanField) – Active. Defined if content in this language can be created or edited
created_date (DateTimeField) – Creation date
last_updated (DateTimeField) – Modification date
machine_translation_enabled (BooleanField) – Machine translatable. Enable or disable machine translations into this language
preferred_mt_provider (CharField) – Machine translation provider. Preferred provider for translations into this language
Relationship fields:
- Parameters:
parent (
ForeignKey
toLanguageTreeNode
) – Source language (related name:children
)region (
ForeignKey
toRegion
) – Region (related name:language_tree_nodes
)language (
ForeignKey
toLanguage
) – Language (related name:language_tree_nodes
)
Reverse relationships:
- Parameters:
children (Reverse
ForeignKey
fromLanguageTreeNode
) – All children of this language tree node (related name ofparent
)
alias of
LanguageTreeNode