Regions

This package contains only the Region model.

Region

class integreat_cms.cms.models.regions.region.Region(*args, **kwargs)[source]

Bases: AbstractBaseModel

Data model representing region.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • name (CharField) – Name

  • common_id (CharField) –

    Community identification number. Number sequence for identifying politically independent administrative units

    See community identification number and Gemeindeschlüssel (German)

  • slug (SlugField) – URL parameter. Unique string identifier without spaces and special characters. Leave blank to generate unique parameter from name

  • status (CharField) –

    Status

    Manage choices in region_status

  • administrative_division (CharField) –

    Administrative division

    Manage choices in administrative_division. Also see administrative division.

  • aliases (JSONField) – Aliases. E.g. smaller municipalities in that area. If empty, the CMS will try to fill this automatically. Specify as JSON.

  • custom_prefix (CharField) – Custom prefix. Enter parts of the name that should not affect sorting. Use this field only if the prefix is not an available choice in the list of administrative divisions above.

  • events_enabled (BooleanField) – Activate events. Whether or not events are enabled in the region

  • locations_enabled (BooleanField) – Activate locations. Whether or not locations are enabled in the region

  • push_notifications_enabled (BooleanField) – Activate push notifications. Whether or not push notifications are enabled in the region

  • latitude (FloatField) – Latitude. The latitude coordinate of an approximate center of the region

  • longitude (FloatField) – Longitude. The longitude coordinate of an approximate center of the region

  • longitude_min (FloatField) – Minimum longitude. The left boundary of the region

  • latitude_min (FloatField) – Minimum latitude. The bottom boundary of the region

  • longitude_max (FloatField) – Maximum longitude. The right boundary of the region

  • latitude_max (FloatField) – Maximum latitude. The top boundary of the region

  • postal_code (CharField) – Postal code. For districts, enter the postcode of the administrative headquarters.

  • admin_mail (EmailField) – Email address of the administrator

  • timezone (CharField) – Timezone

  • created_date (DateTimeField) – Creation date

  • last_updated (DateTimeField) – Modification date

  • statistics_enabled (BooleanField) – Activate statistics. Whether or not statistics are enabled for the region

  • seo_enabled (BooleanField) – Activate SEO section. Enable possibility to fill meta description for pages, events and locations

  • matomo_id (PositiveSmallIntegerField) – Matomo ID. The Matomo ID of this region. Will be automatically derived from the Matomo access token.

  • matomo_token (CharField) – Matomo authentication token. The secret Matomo access token of the region is used to authenticate in API requests

  • page_permissions_enabled (BooleanField) – Activate page-specific permissions. This allows individual users to be granted the right to edit or publish a specific page.

  • chat_enabled (BooleanField) – Activate author chat. This gives all users of this region access to the cross-regional author chat.

  • administrative_division_included (BooleanField) – Include administrative division into name. Determines whether the administrative division is displayed next to the region name. Sorting is always based on the name, independently from the administrative division.

  • short_urls_enabled (BooleanField) – Activate short urls. Please check the box if you want to use short urls.

  • external_news_enabled (BooleanField) – Enable external news. Enable to display external articles in addition to local news managed by the CMS

  • fallback_translations_enabled (BooleanField) – Show content in default language as fallback. Whether or not events and locations are shown in default language as fallback

  • hix_enabled (BooleanField) – Activate HIX analysis. Allow users of this region to analyze understandability of text content via TextLab API.

  • summ_ai_enabled (BooleanField) – Activate automatic translations via SUMM.AI. Whether automatic translations into Easy German with SUMM.AI are enabled

  • mt_renewal_month (PositiveIntegerField) – Credits renewal date for foreign language translation. Budget usage will be reset on the 1st of the month

  • mt_addon_booked (BooleanField) – Add-on package for foreign languages booked. This makes 1.000.000 translation credits available to the region in addition to the 50.000 free ones.

  • mt_midyear_start_month (PositiveIntegerField) – Budget year start date for foreign language translation. Month from which the add-on package was booked

  • mt_budget_used (PositiveIntegerField) – Used budget

  • machine_translate_pages (PositiveIntegerField) – Pages

  • machine_translate_events (PositiveIntegerField) – Events

  • machine_translate_pois (PositiveIntegerField) – Locations

  • integreat_chat_enabled (BooleanField) – Enable Integreat Chat. Toggle the Integreat Chat on/off.

  • zammad_url (URLField) – Zammad-URL. URL pointing to this region’s Zammad instance. Setting this enables Zammad form offers.

  • zammad_access_token (CharField) – Zammad access token. Access token for a Zammad user account. In Zammad, the account must be part of the “Agent” role and have full group permissions for the group:

  • zammad_webhook_token (UUIDField) – Token used by Zammad webhook. Token used by Zammad webhooks to inform the Integreat CMS about changed tickets. The token has to be appended with a token= GET parameter to the webhook path.

  • zammad_chat_handlers (CharField) – Zammad chat handlers. Comma-separated email addresses of the accounts which should automatically be subscribed to new chat tickets. Note that these users must have full group permissions for the group:

  • chat_beta_tester_percentage (IntegerField) – Chat beta tester percentage. Percentage of users selected as beta testers for the Integreat Chat feature

Relationship fields:

Parameters:
  • icon (ForeignKey to MediaFile) – Logo (related name: icon_regions)

  • offers (ManyToManyField to OfferTemplate) – Offers. Integreat offers are extended features apart from pages and events and are usually offered by a third party. In most cases, the url is an external API endpoint which the frontend apps can query and render the results inside the Integreat app. (related name: regions)

Reverse relationships:

Parameters:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

active_languages[source]

This property returns a list of all Language objects which have an active LanguageTreeNode which belongs to this region.

Returns:

A list of all active Language instances of this region

administrative_division[source]

Type: CharField

Administrative division

Choices:

  • CITY

  • DISTRICT

  • RURAL_DISTRICT

  • REGION

  • CITY_AND_DISTRICT

  • URBAN_DISTRICT

  • GOVERNMENTAL_DISTRICT

  • CITY_STATE

  • AREA_STATE

  • FREE_STATE

  • and 4 more

Manage choices in administrative_division. Also see administrative division.

archived_pages[source]

This property returns a QuerySet of all archived pages and their descendants of this region.

Returns:

A QuerySet of all archived pages of this region

backend_edit_link[source]

This function returns the absolute url to the edit form of this region

Returns:

The url

bounding_box[source]

The bounding box of the region

Returns:

A bounding box object

common_id[source]

Type: CharField

Community identification number. Number sequence for identifying politically independent administrative units

See community identification number and Gemeindeschlüssel (German)

default_language[source]

This property returns the language Language which corresponds to the root LanguageTreeNode of this region.

Returns:

The root Language of a region

property explicitly_archived_ancestors_subquery: PageQuerySet[source]

This property returns a subquery for all explicitly archived ancestors of a given page. Needs to be used as part of another query because in order to resolve OuterRef, e.g. in a Subquery or in Exists.

Returns:

A queryset of the explicitly archived ancestors.

full_name[source]

This property returns the full name of a region including its administrative division

Returns:

The full name of the region

get_language_or_404(language_slug: str, only_active: bool = False, only_visible: bool = False) Language[source]

This class method returns the requested language of this region with optional filters active and visible

Parameters:
  • language_slug (str) – The slug of the requested language

  • only_active (bool) – Whether to return only active languages

  • only_visible (bool) – Whether to return only visible languages

Raises:

Http404 – When no language with the given slug exists for this region and this filters

Returns:

The requested Language of this region

Return type:

Language

get_pages(archived: bool = False, prefetch_translations: bool = False, prefetch_major_translations: bool = False, prefetch_public_translations: bool = False, annotate_language_tree: bool = False) PageQuerySet[source]

This method returns either all archived or all non-archived pages of this region. To retrieve all pages independently of their archived-state, use the reverse foreign key pages.

Parameters:
  • archived (bool) – Whether only archived pages should be returned (default: False)

  • prefetch_translations (bool) – Whether the latest translations for each language should be prefetched (default: False)

  • prefetch_major_translations (bool) – Whether the latest major translations for each language should be prefetched (default: False)

  • prefetch_public_translations (bool) – Whether the latest public translations for each language should be prefetched (default: False)

  • annotate_language_tree (bool) – Whether the pages should be annotated with the region’s language tree (default: False)

Returns:

Either the archived or the non-archived pages of this region

Return type:

PageQuerySet

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <Region: Region object (id)>. It is used for logging.

Returns:

The canonical string representation of the region

Return type:

str

get_root_pages() PageQuerySet[source]

This method returns all root pages of this region.

Returns:

This region’s root pages

Return type:

PageQuerySet

get_source_language(language_slug: str) Language | None[source]

This property returns this region’s source language of a given language object

Parameters:

language_slug (str) – The slug of the requested language

Returns:

The source language of the given language in this region

Return type:

Language | None

has_bounding_box[source]

Whether the region has an individual bounding box

Returns:

Whether all required coordinates for the bounding box are set

imprint[source]

This property returns this region’s imprint

Returns:

The imprint of this region

language_node_by_id[source]

This property returns this region’s language tree nodes indexed by ids

Returns:

A mapping from language tree node ids to their language tree nodes in this region

language_node_by_slug[source]

This property returns this region’s language tree nodes indexed by slugs

Returns:

A mapping from language slugs to their language tree nodes in this region

language_tree[source]

This property returns a list of all LanguageTreeNode objects of this region.

Returns:

A list of all language tree nodes of this region

language_tree_root[source]

This property returns the root node of the region’s language tree

Returns:

The region’s language root node

languages[source]

This property returns a list of all Language objects which have a LanguageTreeNode which belongs to this region.

Returns:

A list of all Language instances of this region

last_content_update[source]

Find the latest date at which any content of the region has been modified.

Returns:

the last content update date

latest_page_translations[source]
Returns:

A QuerySet of all PageTranslations of this region that are non-archived and the latest version.

property mt_budget: int[source]

Calculate the maximum translation credit budget (number of words)

Returns:

The region’s total MT budget

property mt_budget_remaining: int[source]

Calculate the remaining translation credit budget (number of words)

Returns:

The region’s remaining MT budget

non_archived_pages[source]

This property returns a QuerySet of all non-archived pages of this region. A page is considered as “non-archived” if its explicitly_archived property is False and all the page’s ancestors are not archived as well.

Returns:

A QuerySet of all non-archived pages of this region

objects = <integreat_cms.cms.models.regions.region.RegionManager object>[source]

Django manager to access the ORM Use Region.objects.all() to fetch all objects.

Custom model manager RegionManager for region objects

outdated_pages(translation_ids: QuerySet | list | None = None) QuerySet[source]

Returns the outdated pages of this region. A page is outdated if it has not been updated in a configurable amount of time.

Parameters:

translation_ids (QuerySet | list | None) – Limit to the result to these ids. If None is passed, all latest page translations will be used.

Returns:

The number of outdated pages of this region.

Return type:

QuerySet

prefix[source]

This property returns the administrative division of a region if it’s included in the name. If this region has no default language, this property returns an empty string

Returns:

The prefix of the region

region_users[source]

This property returns a QuerySet of all User objects which belong to this region and are neither superusers nor staff.

Returns:

A QuerySet of all User object instances of a region

classmethod search(query: str) QuerySet[Region][source]

Searches for all regions which match the given query in their name. :param query: The query string used for filtering the regions :return: A query for all matching objects

Parameters:

query (str)

Return type:

QuerySet[Region]

statistics[source]

This property returns the MatomoApiClient of the current region.

Returns:

The statistics manager

status[source]

Type: CharField

Status

Choices:

  • ACTIVE

  • HIDDEN

  • ARCHIVED

Manage choices in region_status

visible_languages[source]

This property returns a list of all Language objects which have an active & visible LanguageTreeNode which belongs to this region.

Returns:

A list of all active & visible Language instances of this region

class integreat_cms.cms.models.regions.region.RegionManager(*args, **kwargs)[source]

Bases: Manager

This manager annotates each region object with its language tree root node. This is done because it is required to calculate the region’s default_language which is called in full_name.

get_queryset() QuerySet[source]

Get the queryset of regions including the custom attribute language_tree_root which contains the root node of the region’s language tree.

Returns:

The queryset of regions

Return type:

QuerySet

integreat_cms.cms.models.regions.region.format_mt_help_text(help_text: Promise) str[source]

Helper function to lazily format help text with number separators

Parameters:

help_text (Promise) – MT field help text to format

Returns:

formatted help text

Return type:

str