POI Categories

Forms for creating and modifying POI Category and POI Category Translation objects

POI Category Form

class integreat_cms.cms.forms.poi_categories.poi_category_form.POICategoryForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for creating and modifying POICategory objects

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(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.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
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]

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

Clean all of self.data and populate self._errors and self.cleaned_data.

get_context()[source]
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]]

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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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.

is_valid()[source]

Return True if the form has no errors, or False otherwise.

property media[source]

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

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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
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

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

Return a list of BoundField objects that aren’t hidden fields. The opposite of the hidden_fields() method.

POI Category Translation Form

class integreat_cms.cms.forms.poi_categories.poi_category_translation_form.BaseInlinePOICategoryTranslationFormSet(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)[source]

Bases: BaseInlineFormSet

A formset for translations of POI categories

__init__(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)[source]
add_fields(form, index)[source]

Add a hidden field for the object’s primary key.

add_prefix(index)[source]
as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

clean() None[source]

Make sure that at least one translation is given

Raises:

ValidationError – When not a single form contains a valid text

Return type:

None

property cleaned_data[source]

Return a list of form.cleaned_data dicts for every form in self.forms.

default_error_messages = {'missing_management_form': 'ManagementForm data is missing or has been tampered with. Missing fields: %(field_names)s. You may need to file a bug report if the issue persists.', 'too_few_forms': '', 'too_many_forms': ''}[source]
delete_existing(obj, commit=True)[source]

Deletes an existing model instance.

property deleted_forms[source]

Return a list of forms that have been marked for deletion.

deletion_widget[source]

alias of CheckboxInput

edit_only = False[source]
property empty_form[source]
property errors[source]

Return a list of form.errors for every form in self.forms.

property extra_forms[source]

Return a list of all the extra forms in this formset.

forms[source]

Instantiate forms at first property access.

full_clean()[source]

Clean all of self.data and populate self._errors and self._non_form_errors.

get_context()[source]
get_date_error_message(date_check)[source]
classmethod get_default_prefix()[source]
classmethod get_deletion_widget()[source]
get_form_error()[source]
get_form_kwargs(index: int) dict[str, dict[str, Language]][source]

Return additional keyword arguments for each individual formset form. (see get_form_kwargs() and Passing custom parameters to formset forms)

Parameters:

index (int) – The index of the initialized form (will be None if the form being constructed is a new empty form)

Returns:

The form kwargs

Return type:

dict[str, dict[str, Language]]

classmethod get_ordering_widget()[source]
get_queryset()[source]
get_unique_error_message(unique_check)[source]
has_changed()[source]

Return True if data in any form differs from initial.

initial_form_count()[source]

Return the number of forms that are required in this FormSet.

property initial_forms[source]

Return a list of all the initial forms in this formset.

is_multipart()[source]

Return True if the formset needs to be multipart, i.e. it has FileInput, or False otherwise.

is_valid()[source]

Return True if every form in self.forms is valid.

management_form[source]

Return the ManagementForm instance for this FormSet.

property media[source]
model = None[source]
non_form_errors()[source]

Return an ErrorList of errors that aren’t associated with a particular form – i.e., from formset.clean(). Return an empty ErrorList if there are none.

property ordered_forms[source]

Return a list of form in the order specified by the incoming data. Raise an AttributeError if ordering is not allowed.

ordering_widget[source]

alias of NumberInput

render(template_name=None, context=None, renderer=None)[source]
save(commit=True)[source]

Save model instances for every form, adding and changing instances as necessary, and return the list of instances.

save_existing(form, instance, commit=True)[source]

Save and return an existing model instance for the given form.

save_existing_objects(commit=True)[source]
save_new(form, commit=True)[source]

Save and return a new model instance for the given form.

save_new_objects(commit=True)[source]
property template_name[source]
template_name_div = 'django/forms/formsets/div.html'[source]
template_name_p = 'django/forms/formsets/p.html'[source]
template_name_table = 'django/forms/formsets/table.html'[source]
template_name_ul = 'django/forms/formsets/ul.html'[source]
total_error_count()[source]

Return the number of errors across all forms in the formset.

total_form_count()[source]

Return the total number of forms in this FormSet.

unique_fields = {}[source]
validate_unique()[source]
class integreat_cms.cms.forms.poi_categories.poi_category_translation_form.POICategoryTranslationForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for creating and modifying POI category translation objects

Form fields:

Parameters:

kwargs (Any)

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

Initialize POI category translation form

Parameters:

**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.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

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

This method extends the clean()-method to delete translations with an empty name.

Returns:

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

Return type:

dict[str, Any]

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

Clean all of self.data and populate self._errors and self.cleaned_data.

get_context()[source]
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]]

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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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.

is_valid()[source]

Return True if the form has no errors, or False otherwise.

property media[source]

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

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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
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

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

Return a list of BoundField objects that aren’t hidden fields. The opposite of the hidden_fields() method.

integreat_cms.cms.forms.poi_categories.poi_category_translation_form.poi_category_translation_formset_factory() type[source]

Build the formset class

Returns:

The POICategoryTranslationFormset class

Return type:

type