Forms

Forms for creating and modifying database objects. Please refer to django.forms for general information about Django forms (see also: Working with forms).

Custom Content Model Form

class integreat_cms.cms.forms.custom_content_model_form.CustomContentModelForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for the content model forms for pages, events and POIs.

Form fields:

Parameters:

kwargs (Any) –

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

Initialize custom content model form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

add_success_message(request: HttpRequest) None[source]

This adds a success message for a translation form. Requires the attributes “title”, “status” and “foreign_object” on the form instance.

Parameters:

request (HttpRequest) – The current request submitting the translation form

Return type:

None

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

This method extends the clean()-method to verify that a user can modify this content model

Returns:

The cleaned data (see Overriding the clean() method)

Return type:

dict[str, Any]

clean_content() str[source]

Validate the content field (see Overriding the clean() method) and applies changes to <img>- and <a>-Tags to match the guidelines.

Raises:

ValidationError – When a heading 1 (<h1>) is used in the text content

Returns:

The valid content

Return type:

str

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

property media[source]

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

save(commit: bool = True, foreign_form_changed: bool = False) Any[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

  • foreign_form_changed (bool) – Whether or not the foreign form of this translation form was changed

Returns:

The saved content translation object

Return type:

Any

Custom Filter Form

class integreat_cms.cms.forms.custom_filter_form.CustomFilterForm(**kwargs: Any)[source]

Bases: Form

Base class for filter forms

Form fields:

Parameters:

kwargs (Any) –

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

Initialize the custom filter form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

property filters_visible: bool[source]

This function determines whether the filter form is visible by default.

Returns:

Whether any filters (other than search) were changed

property is_enabled: bool[source]

This function determines whether the filters are applied.

Returns:

Whether filtering should be performed

property media[source]

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

Custom Model Form

class integreat_cms.cms.forms.custom_model_form.CustomModelForm(**kwargs: Any)[source]

Bases: ModelForm

Form for populating all text widgets of a ModelForm with the default placeholder “Enter … here”. Use this form as base class instead of django.forms.ModelForm.

Form fields:

Parameters:

kwargs (Any) –

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

Initialize placeholder model form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Raises:

TypeError – If form is instantiated directly without an inheriting subclass

Return type:

None

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

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

This method extends the default clean()-method of the base ModelForm to provide debug logging

Returns:

The cleaned data (see Overriding the clean() method)

Return type:

dict[str, Any]

get_error_messages() list[dict[str, str]][source]

Return all error messages of this form and append labels to field-errors

Returns:

The errors of this form

Return type:

list[dict[str, str]]

property media[source]

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

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

This method extends the default save()-method of the base ModelForm to provide debug logging

Parameters:

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

Returns:

The saved object returned by The save() method

Return type:

Any

Custom Tree Node Form

class integreat_cms.cms.forms.custom_tree_node_form.CustomTreeNodeForm(**kwargs: Any)[source]

Bases: MoveNodeForm

Form for creating and modifying tree node objects

Form fields:

Parameters:

kwargs (Any) –

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

Initialize custom tree node form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

property media[source]

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

classmethod mk_dropdown_tree(model: ModelBase, for_node: None | LanguageTreeNode | Page = None) list[source]

Creates a tree-like list of choices. Overwrites the parent method because the field is hidden anyway and additional queries to render the node titles should be avoided.

Parameters:
  • model (ModelBase) – ~integreat_cms.cms.models.abstract_tree_node.AbstractTreeNode

  • for_node (None | (LanguageTreeNode | Page)) – The instance of this form

Returns:

A list of select options

Return type:

list

Icon Widget

class integreat_cms.cms.forms.icon_widget.IconWidget(attrs=None)[source]

Bases: HiddenInput

A custom widget to render the icon field

get_context(name: str, value: Any | None, attrs: dict[str, Any]) dict[str, dict[str, Any]][source]

This function gets the context of icon fields

Parameters:
  • name (str) – the supplied name

  • value (Any | None) – the supplied values

  • attrs (dict[str, Any]) – the supplied attrs

Returns:

context

Return type:

dict[str, dict[str, Any]]

template_name = 'icon_widget.html'[source]

The template to use for this widget

Machine Translation Form

class integreat_cms.cms.forms.machine_translation_form.MachineTranslationForm(**kwargs: Any)[source]

Bases: CustomContentModelForm

Form for selecting target languages for machine translation of a content object. It should be used as base class for translation forms which enable machine translations.

Form fields:

Parameters:

kwargs (Any) –

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

Initialize MT translation form. If request and language kwargs are missing, MTs are disabled.

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

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]

property media[source]

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

mt_form_is_enabled() NS_NodeQuerySet[source]

Helper method to decide if this form should be shown, or if it should be hidden for the current language due to a lack of MT-compatible child language nodes

Returns:

Whether this form is enabled

Return type:

NS_NodeQuerySet

save(commit: bool = True, foreign_form_changed: bool = False)[source]

Create machine translations and save them to the database

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

  • foreign_form_changed (bool) – Whether or not the foreign form of this translation form was changed

Returns:

The saved content translation object

Return type:

EventTranslation | (PageTranslation | POITranslation)

Object Search Form

class integreat_cms.cms.forms.object_search_form.ObjectSearchForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: Form

Form for searching objects

Form fields:

property media[source]

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