Templatetags
Template tags are our custom extension of the Built-in template tags and filters of The Django template language.
Tags are used to provide arbitrary logic in the rendering process and are surrounded by {%
and %}
.
Filters transform the values of variables and are surrounded by {{
and }}
.
See How to create custom template tags and filters for more information.
Arithmetic
Base Filters
- integreat_cms.cms.templatetags.base_filters.get_mt_visibility(region: Region, perms: PermWrapper) → bool[source]
This tag checks whether either DeepL or Google Translate or SUMM.AI is activated in the region and the user has permission to manage automatic translations.
- integreat_cms.cms.templatetags.base_filters.get_private_member(element: LanguageTreeNodeForm | PageForm, key: SafeString) → BoundField[source]
This filter returns a private member of an element
- Parameters:
element (LanguageTreeNodeForm | PageForm) – The requested object
key (SafeString) – The key of the private variable (without the leading underscore)
- Returns:
The value of the private variable
- Return type:
BoundField
Content Filters
This is a collection of tags and filters which are useful for all content types (Page
,
Event
and POI
).
- integreat_cms.cms.templatetags.content_filters.build_url(target: SafeString, region_slug: str, language_slug: str, content_field: SafeString | str | None = None, content_id: int | None = None) → str[source]
This tag returns the requested language by slug
- Parameters:
- Returns:
list of args
- Return type:
- integreat_cms.cms.templatetags.content_filters.get_int_list(data: QueryDict, list_name: str) → list[int][source]
This filter returns the list data of a one-to-many field as ints.
- integreat_cms.cms.templatetags.content_filters.get_language(language_slug: str) → Language | None[source]
This tag returns the requested language by slug
- integreat_cms.cms.templatetags.content_filters.get_public_translation(instance: AbstractContentModel, language_slug: str) → AbstractContentTranslation | None[source]
This tag returns the most recent public translation of the requested content object in the requested language.
- Parameters:
instance (AbstractContentModel) – The content object instance
language_slug (str) – The slug of the requested language
- Returns:
The translation object of the requested instance or ~integreat_cms.cms.models.pois.poi_translation.POITranslation
- Return type:
AbstractContentTranslation | None
- integreat_cms.cms.templatetags.content_filters.get_translation(instance: AbstractContentModel, language_slug: str) → AbstractContentTranslation | None[source]
This tag returns the most recent translation of the requested content object in the requested language.
- Parameters:
instance (AbstractContentModel) – The content object instance
language_slug (str) – The slug of the requested language
- Returns:
The translation object of the requested instance or ~integreat_cms.cms.models.pois.poi_translation.POITranslation
- Return type:
AbstractContentTranslation | None
- integreat_cms.cms.templatetags.content_filters.is_empty(iterable: MultiValueDict) → bool[source]
This filter checks whether the given iterable is empty.
- Parameters:
iterable (MultiValueDict) – The requested iterable
- Returns:
Whether or not the given iterable is empty
- Return type:
- integreat_cms.cms.templatetags.content_filters.minor_edit_help_text(region: Region, language: Language, translation_form: CustomContentModelForm) → Promise[source]
This tag returns the help text of the minor edit field of the given form
- Parameters:
region (Region) – current region
language (Language) – The current language
translation_form (CustomContentModelForm) – The given model form
- Returns:
The minor edit help text
- Return type:
Promise
- integreat_cms.cms.templatetags.content_filters.minor_edit_label(region: Region, language: Language) → Promise[source]
This tag returns the label of the minor edit field of the given form
- integreat_cms.cms.templatetags.content_filters.object_translation_has_view_perm(user: SimpleLazyObject, obj: AbstractContentTranslation) → bool[source]
This filter accepts any translation of Event, Page or Poi and returns whether this account has the permission to view this object
- Parameters:
user (SimpleLazyObject) – The requested user
obj (AbstractContentTranslation) – The requested object ~integreat_cms.cms.models.events.event_translation.EventTranslation, or ~integreat_cms.cms.models.pois.poi_translation.POITranslation
- Raises:
ValueError – if the object is not a translation of Event, Page or Poi
- Returns:
Whether this account is allowed to view this object
- Return type:
- integreat_cms.cms.templatetags.content_filters.remove(elements: list[Any], element: Any) → list[Any][source]
This tag removes an element from a list.
- integreat_cms.cms.templatetags.content_filters.sort_translation_states(translation_states: dict[str, tuple[Language, str]], second_language: Language) → list[tuple[Language, str]][source]
This filter sorts languages in language tabs
Form Icon Filters
Linkcheck Filters
Model Tags
This is a collection of tags and filters which are useful for all models.
- integreat_cms.cms.templatetags.model_tags.get_model_verbose_name(instance: AbstractBaseModel) → str[source]
This tag returns the readable name of an instance’s model.
- Parameters:
instance (AbstractBaseModel) – The model object instance
- Returns:
The verbose name of the model
- Return type:
Page Filters
This is a collection of tags and filters for Page
objects.
- integreat_cms.cms.templatetags.page_filters.get_depth_in(node: Page, pageset: PageQuerySet) → int[source]
This tag returns the depth of node within the tree/pages in pageset.
:param node : the page :param pageset: The pages (all pages or pages chosen by filter) :return: the depth of node within the tree/pages in pageset
- Parameters:
node (Page)
pageset (PageQuerySet)
- Return type:
- integreat_cms.cms.templatetags.page_filters.get_highest_anscentor_in(node: Page, pageset: PageQuerySet) → Page[source]
This tag returns the highest (farthest) ancestor of node within the tree/pages in pageset.
:param node : the page :param pageset: The pages (all pages or pages chosen by filter) :return: the highest (farthest) ancestor of node within the tree/pages in pageset
- Parameters:
node (Page)
pageset (PageQuerySet)
- Return type:
Parse Struct Time
- integreat_cms.cms.templatetags.parse_struct_time.parse_struct_time(struct_time: struct_time) → date[source]
Converts timestamp to datetime and returns date only
- Parameters:
struct_time (struct_time) – timestamp received from rss feed
- Returns:
proper parsed date
- Return type:
date
PDF Filters
This is a collection of tags and filters for page content used in PDFs (Page
).
- integreat_cms.cms.templatetags.pdf_filters.pdf_strip_fontstyles(instance: str) → str[source]
This tag returns the instance, stripped of inline styling affecting fonts.
POI Filters
This is a collection of tags and filters for points of interest (POI
).
Push Notification Filters
This is a collection of tags and filters for PushNotification
objects.
- integreat_cms.cms.templatetags.push_notification_filters.get_translation(push_notification: PushNotification, language_slug: str) → PushNotificationTranslation[source]
This tag returns the most recent translation of the requested push notification in the requested language.
- Parameters:
push_notification (PushNotification) – The requested push notification
language_slug (str) – The slug of the requested language
- Returns:
The push notification translation
- Return type:
Settings Tags
This contains tags for accessing settings
Svg Tags
Contains a collection of tags for working with svg icons.
Tagifnotempty
- integreat_cms.cms.templatetags.tagifnotempty.tagifnotempty(value: SafeString, args: SafeString) → str[source]
Helper function for template to display property if it’s not left empty :param value: url where that is being investigated :param args: properties that might be left empty :return: Correctly formatted properties
- Parameters:
value (SafeString)
args (SafeString)
- Return type:
Text Filters
This is a collection of tags and filters for strings.
Tree Filters
This is a collection of tags and filters for models which inherit from the MPTT model
AbstractTreeNode
(Page
and
LanguageTreeNode
).
- integreat_cms.cms.templatetags.tree_filters.get_children_ids(node: Page) → list[int][source]
This filter returns the ids of all the node’s direct children.
- integreat_cms.cms.templatetags.tree_filters.get_descendant_ids(node: LanguageTreeNode | Page) → list[int][source]
This filter returns the ids of all the node’s descendants.
- Parameters:
node (LanguageTreeNode | Page) – The requested node
- Returns:
The list of all the node’s descendants’ ids
- Return type:
Url Tags
Contains a collection of tags for working with urls.
- integreat_cms.cms.templatetags.url_tags.add_queries(url: str, key: str, value: str | int) → str[source]
This filter adds a query to an url
User Filters
This is a collection of tags and filters which are useful for all user forms