Users

Forms for creating and modifying user objects

Authentication Form

class integreat_cms.cms.forms.users.authentication_form.AuthenticationForm(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 to check the password of an already authenticated user. Used for critical operations where a valid session might not be enough (e.g. modifying 2-FA options).

Form fields:

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

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

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

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

Organization Field

class integreat_cms.cms.forms.users.organization_field.OrganizationField(queryset, *, empty_label='---------', required=True, widget=None, label=None, initial=None, help_text='', to_field_name=None, limit_choices_to=None, blank=False, **kwargs)[source]

Bases: ModelChoiceField

ModelChoiceField which puts the organization’s region id as data attribute on <options>

__init__(queryset, *, empty_label='---------', required=True, widget=None, label=None, initial=None, help_text='', to_field_name=None, limit_choices_to=None, blank=False, **kwargs)[source]
bound_data(data, initial)[source]

Return the value that should be shown for this field on render of a bound form, given the submitted POST data for the field and the initial data, if any.

For most fields, this will simply be data; FileFields need to handle it a bit differently.

property choices[source]
clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

default_error_messages = {'invalid_choice': 'Select a valid choice. That choice is not one of the available choices.'}[source]
default_validators = [][source]
empty_values = [None, '', [], (), {}][source]
get_bound_field(form, field_name)[source]

Return a BoundField instance that will be used when accessing the form field in a template.

get_limit_choices_to()[source]

Return limit_choices_to for this form field.

If it is a callable, invoke it and return the result.

has_changed(initial, data)[source]

Return True if data differs from initial.

hidden_widget[source]

alias of HiddenInput

iterator[source]

alias of ModelChoiceIterator

label_from_instance(obj: Organization) dict[str, Any][source]

Normally, this function convert objects into strings and generate the labels for the choices presented by this object.

In this case, we abuse the function also to pass the organization’s region id to the create_option() function to enable it to use it as data attribute.

Parameters:

obj (Organization) – The name of the option

Returns:

A dict of the real label and the organization’s region id

Return type:

dict[str, Any]

prepare_value(value)[source]
property queryset[source]
run_validators(value)[source]
to_python(value)[source]

Return a string.

valid_value(value)[source]

Check to see if the provided value is a valid choice.

validate(value)[source]

Validate that the input is in self.choices.

widget[source]

The widget to use when rendering this type of Field.

alias of OrganizationFieldWidget

widget_attrs(widget)[source]

Given a Widget instance (not a Widget class), return a dictionary of any HTML attributes that should be added to the Widget, based on this Field.

class integreat_cms.cms.forms.users.organization_field.OrganizationFieldWidget(attrs=None, choices=())[source]

Bases: Select

Select widget which puts the organization’s region id as data attribute on <options>

__init__(attrs=None, choices=())[source]
add_id_index = False[source]
allow_multiple_selected = False[source]
build_attrs(base_attrs, extra_attrs=None)[source]

Build an attribute dictionary.

checked_attribute = {'selected': True}[source]
create_option(name: str, value: ModelChoiceIteratorValue | str, label: dict[str, Any] | str, selected: bool, index: int, subindex: Any | None = None, attrs: dict[str, str] | None = None) dict[str, Any][source]

This function creates an option which can be selected in the organization field

Parameters:
  • name (str) – The name of the option

  • value (ModelChoiceIteratorValue | str) – the value of the option (the page id)

  • label (dict[str, Any] | str) – The label (and optionally the region id) of the option

  • selected (bool) – Whether or not the option is selected

  • index (int) – The index of the option

  • subindex (Any | None) – The subindex of the option

  • attrs (dict[str, str] | None) – The attributes of the option

Returns:

The option dict

Return type:

dict[str, Any]

format_value(value)[source]

Return selected values as a list.

get_context(name, value, attrs)[source]
id_for_label(id_, index='0')[source]

Use an incremented id for each option where the main widget references the zero index.

input_type = 'select'[source]
property is_hidden[source]
is_localized = False[source]
is_required = False[source]
property media[source]
needs_multipart_form = False[source]
optgroups(name, value, attrs=None)[source]

Return a list of optgroups for this widget.

option_inherits_attrs = False[source]
option_template_name = 'django/forms/widgets/select_option.html'[source]
options(name, value, attrs=None)[source]

Yield a flat list of options for this widget.

render(name, value, attrs=None, renderer=None)[source]

Render the widget as an HTML string.

subwidgets(name, value, attrs=None)[source]

Yield all “subwidgets” of this widget. Used to enable iterating options from a BoundField for choice widgets.

supports_microseconds = True[source]
template_name = 'django/forms/widgets/select.html'[source]
use_fieldset = False[source]
use_required_attribute(initial)[source]

Don’t render ‘required’ if the first <option> has a value, as that’s invalid HTML.

value_from_datadict(data, files, name)[source]

Given a dictionary of data and this widget’s name, return the value of this widget or None if it’s not provided.

value_omitted_from_data(data, files, name)[source]

Password Reset Form

class integreat_cms.cms.forms.users.password_reset_form.CustomPasswordResetForm(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: PasswordResetForm

A custom form to attach the logo to the password reset email

Form fields:

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

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

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

get_users(email)[source]

Given an email, return matching user(s) who should receive a reset.

This allows subclasses to more easily customize the default policies that prevent inactive users and users with unusable passwords from resetting their password.

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(domain_override=None, subject_template_name='registration/password_reset_subject.txt', email_template_name='registration/password_reset_email.html', use_https=False, token_generator=<django.contrib.auth.tokens.PasswordResetTokenGenerator object>, from_email=None, request=None, html_email_template_name=None, extra_email_context=None)[source]

Generate a one-use only link for resetting password and send it to the user.

send_mail(subject_template_name: str, email_template_name: str, context: dict[str, Any], from_email: Any | None, to_email: str, html_email_template_name: str) None[source]

Send a django.core.mail.EmailMultiAlternatives to to_email.

Parameters:
  • subject_template_name (str) – The template to be used to render the subject of the email

  • email_template_name (str) – The template to be used to render the text email

  • context (dict[str, Any]) – The template context variables

  • from_email (Any | None) – The email address of the sender

  • to_email (str) – The email address of the recipient

  • html_email_template_name (str) – The template to be used to render the HTML email

Return type:

None

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

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

Passwordless Authentication Form

class integreat_cms.cms.forms.users.passwordless_authentication_form.PasswordlessAuthenticationForm(*args: Any, request: HttpRequest | None = None, **kwargs: Any)[source]

Bases: Form

Form class for authenticating users without using passwords but other authentication methods like FIDO2.

Form fields:

  • username: Username (UsernameField)

Parameters:
  • args (Any)

  • request (HttpRequest | None)

  • kwargs (Any)

__init__(*args: Any, request: HttpRequest | None = None, **kwargs: Any) None[source]

Render passwordless authentication form for HTTP GET requests

Parameters:
  • request (HttpRequest | None) – Object representing the user call

  • *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_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()[source]

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

clean_username() str[source]

Checks the input of the user to enable authentication

Raises:

ValidationError – If the given username or email is invalid

Returns:

The cleaned username

Return type:

str

default_renderer = None[source]
error_messages = {'disabled': 'Your account is not activated for passwordless authentication. Please use the default login.', 'inactive': 'This account is inactive.', 'invalid_login': 'The username or email address is incorrect.', 'not_available': 'In order to use passwordless authentication, you have to configure at least one 2-factor authentication method.'}[source]

The different reasons why passwordless authentication might not be possible

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_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]
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]
user: User | None = None[source]

The user who tries to login without password

visible_fields()[source]

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

Region User Form

class integreat_cms.cms.forms.users.region_user_form.RegionUserForm(region: Region, **kwargs: Any)[source]

Bases: UserForm

Form for creating and modifying region user objects

Form fields:

Parameters:
  • region (Region)

  • kwargs (Any)

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

Initialize region user form

Parameters:
  • region (Region) – The current region

  • **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]

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

Returns:

The cleaned form data

Return type:

dict[str, Any]

clean_email() str[source]

Make the email lower case (see Overriding the clean() method)

Returns:

The email in lower case

Return type:

str

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) User[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 user object

Return type:

User

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.

User Email Form

class integreat_cms.cms.forms.users.user_email_form.UserEmailForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for modifying user email addresses

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.

User Filter Form

class integreat_cms.cms.forms.users.user_filter_form.UserFilterForm(**kwargs: Any)[source]

Bases: CustomFilterForm

Form for filtering user objects

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

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

apply(users: QuerySet[User]) QuerySet[User][source]

Filter the users list according to the given filter data

Parameters:

users (QuerySet[User]) – The list of users

Returns:

The filtered page list

Return type:

QuerySet[User]

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

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
filter_by_query(users: QuerySet[User]) QuerySet[User][source]

Filter the pages list by a given search query

Parameters:

users (QuerySet[User]) – The list of users

Returns:

The filtered page list

Return type:

QuerySet[User]

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

full_clean()[source]

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

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

property is_enabled: bool[source]

This function determines whether the filters are applied.

Returns:

Whether filtering should be performed

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

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

User Form

class integreat_cms.cms.forms.users.user_form.UserForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for creating and modifying user objects

Form fields:

Parameters:

kwargs (Any)

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

Initialize user 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]

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

Returns:

The cleaned form data

Return type:

dict[str, Any]

clean_email() str[source]

Make the email lower case (see Overriding the clean() method)

Returns:

The email in lower case

Return type:

str

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) User[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 user object

Return type:

User

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.

User Password Form

class integreat_cms.cms.forms.users.user_password_form.UserPasswordForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for changing a user’s password

Form fields:

  • old_password: My old password (CharField)

  • new_password: My new password (CharField)

  • new_password_confirm: Confirm my new password (CharField)

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]

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

Returns:

The cleaned form data

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) User[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 user object

Return type:

User

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.

User Preferences Form

class integreat_cms.cms.forms.users.user_preferences_form.UserPreferencesForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for changing a user’s preferences

Form fields:

  • distribute_sidebar_boxes: Automatically distribute sidebar boxes (BooleanField)

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.