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:

property media[source]

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

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>

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]

widget[source]

The widget to use when rendering this type of Field.

alias of OrganizationFieldWidget

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>

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]

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:

property media[source]

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

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

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

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

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

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

user: User | None = None[source]

The user who tries to login without password

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

property media[source]

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

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)

property media[source]

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

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)

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]

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

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

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

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

property media[source]

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

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

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)

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.

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

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)

property media[source]

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