Users

This package contains all data models related to users: user.

User

class integreat_compass.cms.models.users.user.CustomUserManager(*args, **kwargs)

Bases: BaseUserManager

This manager provides custom methods for user creation

create_superuser(email, display_name, password=None, **extra_fields)

Create a new super user

Parameters:
  • email (str) – email address of the user, also used in lieu of username

  • display_name (str) – name used for comments etc.

  • password (str) – user password

  • extra_fields (dict) – additional fields

Returns:

the newly created user

Return type:

User

create_user(email, display_name, password=None, group=None, **extra_fields)

Create a new user and ensure they are added to the correct group (if any)

Parameters:
  • email (str) – email address of the user, also used in lieu of username

  • display_name (str) – name used for comments etc.

  • password (str) – user password

  • group (str) – either None or one of CHOICES

  • extra_fields (dict) – additional fields

Returns:

the newly created user

Return type:

User

class integreat_compass.cms.models.users.user.User(*args, **kwargs)

Bases: AbstractBaseUser, PermissionsMixin, 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 user has all permissions without explicitly assigning them.

  • email (EmailField) – Email. Valid email address for this user

  • display_name (CharField) – Display name. This name will be shown as the author of votes, comments, etc.

  • is_active (BooleanField) – Is active

  • is_staff (BooleanField) – Is staff

Relationship fields:

Parameters:
  • 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)

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

REQUIRED_FIELDS = ['display_name']
USERNAME_FIELD = 'email'
comments

Type: Reverse ForeignKey from Comment

All comments of this user (related name of creator)

display_name

Type: CharField

Display name. This name will be shown as the author of votes, comments, etc.

email

Type: EmailField

Email. Valid email address for this user

favorite

Type: Reverse ForeignKey from Favorite

All favorite of this user (related name of creator)

get_repr()

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

group

Return the primary group of this user

Returns:

The first group of this user

Return type:

Group

groups

Type: 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)

id

Type: BigAutoField

Primary key: ID

is_active

Type: BooleanField

Is active

is_staff

Type: BooleanField

Is staff

is_superuser

Type: BooleanField

Superuser status. Designates that this user has all permissions without explicitly assigning them.

last_login

Type: DateTimeField

Last login

logentry_set

Type: Reverse ForeignKey from LogEntry

All log entries of this user (related name of user)

objects = <integreat_compass.cms.models.users.user.CustomUserManager object>
offer_contact

Type: Reverse ForeignKey from Contact

All offer contact of this user (related name of creator)

offer_set

Type: Reverse ForeignKey from Offer

All offers of this user (related name of creator)

organization

Type: Reverse ForeignKey from Organization

All organization of this user (related name of creator)

password

Type: CharField

Password

user_permissions

Type: ManyToManyField to Permission

User permissions. Specific permissions for this user. (related name: user_set)

votes

Type: Reverse ForeignKey from Vote

All votes of this user (related name of creator)