Users

This package contains all user-related data models: User, Organization and FidoKey (see also django.contrib.auth.models.User for Django’s base user model)

Organization

class integreat_cms.cms.models.users.organization.Organization(*args, **kwargs)[source]

Bases: AbstractBaseModel

Data model representing an organization

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

archive() bool[source]

Archives the organizations

Return type:

bool

backend_edit_link[source]

This function returns the absolute url to the edit form of this region

Returns:

The url

delete(*args: list, **kwargs: dict) bool[source]

Deletes the organization

Parameters:
  • *args (list) – The supplied arguments

  • **kwargs (dict) – The supplied keyword arguments

Return type:

bool

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <Organization: Organization object (id)>. It is used for logging.

Returns:

The canonical string representation of the organization

Return type:

str

property is_used: bool[source]
Returns:

whether this organization is used by another model

property num_contents: int[source]
Returns:

the current number of maintained pages of an organization object

property num_members: int[source]
Returns:

the current number of members of an organization object

replace_urls(urls_to_replace: dict[str, str], user: User | None = None, commit: bool = True) None[source]

Function to replace links that are in the translation and match the given keyword search

Parameters:
Return type:

None

restore() None[source]

Restores the organization

Return type:

None

classmethod search(region: Region, query: str) QuerySet[source]

Searches for all organizations which match the given query in their name. :param query: The query string used for filtering the organizations :return: A query for all matching objects

Parameters:
Return type:

QuerySet

classmethod suggest(**kwargs: Any) list[dict[str, Any]][source]

Suggests keywords for organization search

Parameters:

**kwargs (Any) – The supplied kwargs

Returns:

Json object containing all matching elements, of shape {title: str, url: str, type: str}

Return type:

list[dict[str, Any]]

property title: str[source]

This function return the name of organization. Alias for link list template.

Role

class integreat_cms.cms.models.users.role.Role(*args, **kwargs)[source]

Bases: AbstractBaseModel

Meta information about the default Django auth group model

Parameters:

Relationship fields:

Parameters:

group (OneToOneField to Group) – Django auth group (related name: role)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

english_name[source]

This returns the english name of a role which is used for logging

Returns:

The english name of the role

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <Role: Role object (id)>. It is used for logging.

Returns:

The canonical string representation of the role

Return type:

str

name[source]

Type: CharField

Name

Choices:

  • MANAGEMENT

  • EDITOR

  • AUTHOR

  • EVENT_MANAGER

  • OBSERVER

  • SERVICE_TEAM

  • CMS_TEAM

  • MARKETING_TEAM

Manage choices in roles

User

Custom user model that is used instead of the default Django user model

class integreat_cms.cms.models.users.user.CustomUserManager(*args, **kwargs)[source]

Bases: UserManager

This manager prefetches the regions of each user because they are needed for permissions checks and the region selection anyway

get_queryset() QuerySet[source]

Get the queryset of users including the prefetched regions

Returns:

The queryset of users

Return type:

QuerySet

class integreat_cms.cms.models.users.user.User(*args, **kwargs)[source]

Bases: AbstractUser, AbstractBaseModel

A custom User model that replaces the default Django User model

Parameters:
  • id (BigAutoField) – Primary key: ID

  • password (CharField) – Password

  • last_login (DateTimeField) – Last login

  • is_superuser (BooleanField) – Superuser status. Designates that this account has all permissions without explicitly assigning them.

  • username (CharField) – Username. Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.

  • first_name (CharField) – First name

  • last_name (CharField) – Last name

  • email (EmailField) – Email address

  • is_staff (BooleanField) – Staff status. Designates whether the user can log into this admin site.

  • is_active (BooleanField) – Active. Designates whether this account should be treated as active. Unselect this instead of deleting accounts.

  • date_joined (DateTimeField) – Date joined

  • chat_last_visited (DateTimeField) – Last chat visit date. The date and time when the user did read the chat the last time

  • expert_mode (BooleanField) – Experienced user. Enable this option to display additional features like XLIFF import/export, page filtering, mirrored pages, page-based permissions and status information for broken links

  • has_seen_page_tree_tutorial (BooleanField) – Page tree tutorial seen. Has seen tutorial for page tree

  • totp_key (CharField) – TOTP key. Will be used to generate TOTP codes

  • passwordless_authentication_enabled (BooleanField) – Enable passwordless authentication. Enable this option to activate the passwordless login routine for this account

  • webauthn_id (BinaryField) – Webauthn id

Relationship fields:

Parameters:
  • organization (ForeignKey to Organization) – Organization. This allows the user to edit and publish all pages for which the organisation is registered as the responsible organisation (related name: members)

  • groups (ManyToManyField to Group) – Groups. The groups this user belongs to. A user will get all permissions granted to each of their groups. (related name: user_set)

  • user_permissions (ManyToManyField to Permission) – User permissions. Specific permissions for this user. (related name: user_set)

  • regions (ManyToManyField to Region) – Regions. The regions to which the user has access (related name: users)

Reverse relationships:

Parameters:
exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

access_granted_pages(region: Region) QuerySet[Page][source]

Get a list of all pages the user has been given explicit rights to edit

Parameters:

region (Region)

Return type:

QuerySet[Page]

distinct_region[source]

If the user is no staff member and has exactly one region, this property returns it

Returns:

The only region of this user

property full_user_name: str[source]

Return the full name of the user. If either the first or the last name are present, return them, otherwise return the username.

Returns:

The full name of the user

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <User: User object (id)>. It is used for logging.

Returns:

The canonical string representation of the user

Return type:

str

has_totp[source]

If the user has totp configured

Returns:

True if the user has totp configured, False otherwise

objects = <integreat_cms.cms.models.users.user.CustomUserManager object>[source]

Django manager to access the ORM Use User.objects.all() to fetch all objects.

Custom model manager for user objects

role[source]

We refer to Django user groups as roles.

Returns:

The role of this user

classmethod suggest(**kwargs: Any) list[dict[str, Any]][source]

Suggests keywords for user search

Parameters:

**kwargs (Any) – The supplied kwargs

Returns:

Json object containing all matching elements, of shape {title: str, url: str, type: str}

Return type:

list[dict[str, Any]]

property unread_chat_messages: QuerySet[ChatMessage][source]

Return all unread messages of this user

Returns:

The unread messages of this user

update_chat_last_visited() datetime[source]

Update the chat_last_visited to the current time

Returns:

the previous chat_last_visited value

Return type:

datetime

User Fido Key

class integreat_cms.cms.models.users.user_fido_key.FidoKey(*args, **kwargs)[source]

Bases: AbstractBaseModel

Data model representing a user’s FIDO key

Parameters:

Relationship fields:

Parameters:

user (ForeignKey to User) – User (related name: fido_keys)

exception DoesNotExist[source]

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned[source]

Bases: MultipleObjectsReturned

get_repr() str[source]

This overwrites the default Django __repr__() method which would return <UserMfaKey: UserMfaKey object (id)>. It is used for logging.

Returns:

The canonical string representation of the user MFA

Return type:

str