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
- disabled_options: list[OfferTemplate] = [][source]
- id_for_label(id_, index=None)[source]
Don’t include for=”field_0” in <label> to improve accessibility when using a screen reader, in addition clicking such a label would toggle the first input.
- subwidgets(name, value, attrs=None)[source]
Yield all “subwidgets” of this widget. Used to enable iterating options from a BoundField for choice widgets.
- 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:
name
: Name (CharField
)common_id
: Community identification number (CharField
)slug
: URL parameter (SlugField
)events_enabled
: Activate events (BooleanField
)locations_enabled
: Activate locations (BooleanField
)chat_enabled
: Activate author chat (BooleanField
)push_notifications_enabled
: Activate push notifications (BooleanField
)latitude
: Latitude (FloatField
)longitude
: Longitude (FloatField
)longitude_min
: Minimum longitude (FloatField
)latitude_min
: Minimum latitude (FloatField
)longitude_max
: Maximum longitude (FloatField
)latitude_max
: Maximum latitude (FloatField
)postal_code
: Postal code (CharField
)admin_mail
: Email address of the administrator (EmailField
)statistics_enabled
: Activate statistics (BooleanField
)matomo_id
: Matomo ID (IntegerField
)matomo_token
: Matomo authentication token (CharField
)status
: Status (TypedChoiceField
)page_permissions_enabled
: Activate page-specific permissions (BooleanField
)administrative_division
: Administrative division (TypedChoiceField
)aliases
: Aliases (JSONField
)icon
: Logo (ModelChoiceField
)administrative_division_included
: Include administrative division into name (BooleanField
)offers
: Offers (ModelMultipleChoiceField
)short_urls_enabled
: Activate short urls (BooleanField
)seo_enabled
: Activate SEO section (BooleanField
)custom_prefix
: Custom prefix (CharField
)external_news_enabled
: Enable external news (BooleanField
)timezone
: Timezone (CharField
)fallback_translations_enabled
: Show content in default language as fallback (BooleanField
)summ_ai_enabled
: Activate automatic translations via SUMM.AI (BooleanField
)hix_enabled
: Activate HIX analysis (BooleanField
)mt_renewal_month
: Credits renewal date for foreign language translation (TypedChoiceField
)mt_addon_booked
: Add-on package for foreign languages booked (BooleanField
)mt_midyear_start_month
: Budget year start date for foreign language translation (TypedChoiceField
)integreat_chat_enabled
: Enable Integreat Chat (BooleanField
)zammad_url
: Zammad-URL (URLField
)zammad_access_token
: Zammad access token (CharField
)zammad_chat_handlers
: Zammad chat handlers (CharField
)chat_beta_tester_percentage
: Chat beta tester percentage (IntegerField
)duplicated_region
: Copy languages, pages and media from another region (ModelChoiceField
)duplication_keep_status
: Keep publication status of pages (BooleanField
)duplication_keep_translations
: Copy languages and content translations (BooleanField
)duplication_pbo_behavior
: Page based offers cloning behavior (ChoiceField
)timezone_area
: Timezone area (ChoiceField
)mt_midyear_start_enabled
: Budget year start differs from the renewal date (BooleanField
)zammad_offers
: Zammad forms (ModelMultipleChoiceField
)
- 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
- add_error(field, error)[source]
Update the content of self._errors.
The field argument is the name of the field to which the errors should be added. If it’s None, treat the errors as NON_FIELD_ERRORS.
The error argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. An “error” can be either a simple string or an instance of ValidationError with its message attribute set and a “list or dictionary” can be an actual list or dict or an instance of ValidationError with its error_list or error_dict attribute set.
If error is a dictionary, the field argument must be None and errors will be added to the fields that correspond to the keys of the dictionary.
- add_error_messages(request: HttpRequest) None [source]
This function accepts the current request and adds the form’s error messages to the message queue of
django.contrib.messages
.- Parameters:
request (HttpRequest) – The current request submitting the form
- Return type:
None
- add_initial_prefix(field_name)[source]
Add an ‘initial’ prefix for checking dynamic initial values.
- add_prefix(field_name)[source]
Return the field name with a prefix appended, if this Form has a prefix set.
Subclasses may wish to override.
- static autofill_bounding_box(cleaned_data: dict[str, Any]) dict[str, Any] [source]
Automatically fill the bounding box coordinates
- clean() dict[str, Any] [source]
Validate form fields which depend on each other, see
django.forms.Form.clean()
- clean_aliases() dict [source]
Validate the aliases field (see Overriding the clean() method).
- Returns:
The valid aliases
- Return type:
- 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:
- clean_hix_enabled() bool [source]
Validate the hix_enabled field (see Overriding the clean() method).
- Returns:
The validated field
- Return type:
- clean_slug() str [source]
Validate the slug field (see Overriding the clean() method)
- Returns:
A unique slug based on the input value
- Return type:
- 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:
- clean_zammad_access_token() str [source]
Validate the zammad_access_token field (see Overriding the clean() method). If the value is empty, keep the original one.
- Returns:
The validated field
- Return type:
- clean_zammad_url() str | None [source]
Validate the zammad_url field (see Overriding the clean() method).
- Returns:
The validated field
- Return type:
str | None
- get_error_messages() list[dict[str, str]] [source]
Return all error messages of this form and append labels to field-errors
- get_initial_for_field(field, field_name)[source]
Return initial data for field on form. Use initial data from the form or the field, in that order. Evaluate callable values.
Return a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.
- is_multipart()[source]
Return True if the form needs to be multipart-encoded, i.e. it has FileInput, or False otherwise.
- non_field_errors()[source]
Return an ErrorList of errors that aren’t associated with a particular field – i.e., from Form.clean(). Return an empty ErrorList if there are none.
- order_fields(field_order)[source]
Rearrange the fields according to field_order.
field_order is a list of field names specifying the order. Append fields not included in the list in the default order for backward compatibility with subclasses not overriding field_order. If field_order is None, keep all fields in the order defined in the class. Ignore unknown fields in field_order to allow disabling fields in form subclasses without redefining ordering.
- save(commit: bool = True) Region [source]
This method extends the default
save()
-method of the baseModelForm
to set attributes which are not directly determined by input fields.
- 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.
- integreat_cms.cms.forms.regions.region_form.duplicate_imprint(source_region: Region, target_region: Region, only_root: bool = False) None [source]
Function to duplicate the imprint from one region to another.
- 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 = '', only_root: bool = False) 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
only_root (bool) – Set if only the root node should be copied, not its children
- 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.
- 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
- 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, only_root: bool = False) 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
only_root (bool) – Set if only the root node should be copied, not its children
- 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.
- 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