Regions

Forms for creating and modifying region objects

Region Form

class integreat_cms.cms.forms.regions.region_form.CheckboxSelectMultipleWithDisabled(attrs=None, choices=())[source]

Bases: CheckboxSelectMultiple

This class adds functionality for disabling certain choices in the CheckboxSelectMultiple widget

create_option(*args: Any, **kwargs: Any) dict[str, Any][source]

Overwrites the parent’s method in order to disable a set of pre-determined options

Returns:

a single option

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

dict[str, Any]

class integreat_cms.cms.forms.regions.region_form.RegionForm(*args: Any, **kwargs: Any)[source]

Bases: CustomModelForm

Form for creating and modifying region objects

Form fields:

Parameters:
  • args (Any) –

  • kwargs (Any) –

__init__(*args: Any, **kwargs: Any) None[source]

Initialize region form

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Return type:

None

static autofill_bounding_box(cleaned_data: dict[str, Any]) dict[str, Any][source]

Automatically fill the bounding box coordinates

Parameters:

cleaned_data (dict[str, Any]) – The partially cleaned data

Returns:

The updated cleaned data

Return type:

dict[str, Any]

clean() dict[str, Any][source]

Validate form fields which depend on each other, see django.forms.Form.clean()

Returns:

The cleaned form data

Return type:

dict[str, Any]

clean_aliases() dict[source]

Validate the aliases field (see Overriding the clean() method).

Returns:

The valid aliases

Return type:

dict

clean_custom_prefix() str[source]

Validate the custom prefix field. (see Overriding the clean() method)

Returns:

The given prefix or None if it is invalid

Return type:

str

clean_hix_enabled() bool[source]

Validate the hix_enabled field (see Overriding the clean() method).

Returns:

The validated field

Return type:

bool

clean_slug() str[source]

Validate the slug field (see Overriding the clean() method)

Returns:

A unique slug based on the input value

Return type:

str

clean_summ_ai_enabled() bool[source]

Validate the summ_ai_enabled field (see Overriding the clean() method)

Returns:

The validated field whether SUMM.AI is enabled

Return type:

bool

property media[source]

Return all media required to render the widgets on this form.

save(commit: bool = True) Region[source]

This method extends the default save()-method of the base ModelForm to set attributes which are not directly determined by input fields.

Parameters:

commit (bool) – Whether or not the changes should be written to the database

Returns:

The saved region object

Return type:

Region

integreat_cms.cms.forms.regions.region_form.create_and_replace_links_async(source_region: Region, region: Region) None[source]

Create all links for the latest versions of the region’s page translations, then replace all links in the content. This is run as a background task.

Parameters:
  • source_region (Region) – The region with the slug of the to be replaced links

  • region (Region) – The region in which the links should be replaced and created

Return type:

None

integreat_cms.cms.forms.regions.region_form.duplicate_imprint(source_region: Region, target_region: Region) None[source]

Function to duplicate the imprint from one region to another.

Parameters:
  • source_region (Region) – the source region from which the imprint should be duplicated

  • target_region (Region) – the target region

Return type:

None

integreat_cms.cms.forms.regions.region_form.duplicate_language_tree(source_region: Region, target_region: Region, source_parent: LanguageTreeNode | None = None, target_parent: LanguageTreeNode | None = None, logging_prefix: str = '') None[source]

Function to duplicate the language tree of one region to another.

Usage: duplicate_language_tree(source_region, target_region)

This is a recursive function to walk the whole language tree. It starts at root level with the default parent None. The recursion is necessary because the new nodes need their correct (also duplicated) parent node.

Parameters:
  • source_region (Region) – The region from which the language tree should be duplicated

  • target_region (Region) – The region to which the language tree should be added

  • source_parent (LanguageTreeNode | None) – The current parent node id of the recursion

  • target_parent (LanguageTreeNode | None) – The node of the target region which is the duplicate of the source parent node

  • logging_prefix (str) – recursion level to get a pretty log output

Return type:

None

integreat_cms.cms.forms.regions.region_form.duplicate_media(source_region: Region, target_region: Region) None[source]

Function to duplicate all media of one region to another.

Parameters:
  • source_region (Region) – the source region from which the pages should be duplicated

  • target_region (Region) – the target region

Return type:

None

integreat_cms.cms.forms.regions.region_form.duplicate_page_translations(source_page: Page, target_page: Page, logging_prefix: str, keep_status: bool) None[source]

Duplicate all translations of a given source page to a given target page

Parameters:
  • source_page (Page) – The given source page

  • target_page (Page) – The desired target page

  • logging_prefix (str) – The prefix to be used for logging

  • keep_status (bool) – Parameter to indicate whether the status of the cloned pages should be kept

Return type:

None

integreat_cms.cms.forms.regions.region_form.duplicate_pages(source_region: Region, target_region: Region, source_parent: Page | None = None, target_parent: Page | None = None, logging_prefix: str = '', keep_status: bool = False, offers_to_discard: QuerySet[OfferTemplate] | None = None) None[source]

Function to duplicate all non-archived pages from one region to another

Usage: duplicate_pages(source_region, target_region)

This is a recursive function to walk the whole page tree. It starts at root level with the default parent None. The recursion is necessary because the new pages need their correct (also duplicated) parent page.

Parameters:
  • source_region (Region) – The region from which the pages should be duplicated

  • target_region (Region) – The region to which the pages should be added

  • source_parent (Page | None) – The current parent page id of the recursion

  • target_parent (Page | None) – The page of the target region which is the duplicate of the source parent page

  • logging_prefix (str) – Recursion level to get a pretty log output

  • keep_status (bool) – Parameter to indicate whether the status of the cloned pages should be kept

  • offers_to_discard (QuerySet[OfferTemplate] | None) – Offers which might be embedded in the source region, but not in the target region

Return type:

None

integreat_cms.cms.forms.regions.region_form.find_links(region: Region) None[source]

Find all link objects in the latest versions of the region’s page translations

Parameters:

region (Region) – The region which should be scanned for links

Return type:

None

integreat_cms.cms.forms.regions.region_form.get_timezone_area_choices() list[tuple[str, str]][source]

This method generates the options for the first timezone dropdown. It displays the general area of a country or city. Often the continent.

Returns:

A list of the general areas of the timezones

Return type:

list[tuple[str, str]]

integreat_cms.cms.forms.regions.region_form.get_timezone_choices() list[tuple[str, str]][source]

This method generates the options for the second timezone dropdown

Returns:

A list of all available timezones

Return type:

list[tuple[str, str]]

integreat_cms.cms.forms.regions.region_form.replace_internal_links(source_region: Region, region: Region) None[source]

Replace all internal link objects with the latest versions of the region’s page translations

Parameters:
  • source_region (Region) – The region with the slug of the to be replaced links

  • region (Region) – The region in which the links should be replaced

Return type:

None