loefsys.users.models.user module

Module defining the user account model for the website.

class loefsys.users.models.user.UserManager(*args, **kwargs)

Bases: BaseUserManager

Manager for the User model.

Basically a copy of the regular UserManager, but without the username.

use_in_migrations = True

If set to True the manager will be serialized into migrations and will thus be available in e.g. RunPython operations.

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

Create and save a regular user with the given email and password.

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

Create and save a superuser with the given email and password.

class loefsys.users.models.user.OverwriteStorage(*args, **kwargs)

Bases: FileSystemStorage

Custom storage class that overwrites files with the same name.

Needed because when a user uploads a new profile picture, the old one would otherwise still be present together with the new one that gets renamed.

get_available_name(name, max_length=None)

Given the desired name, derive and return a name that is available.

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

Bases: AbstractBaseUser, PermissionsMixin, NameMixin, Model Extensions

The user model for authentication on the Loefbijter website.

A user account can be made for two use cases. First, when a member registers at Loefbijter, an account is made for them as it is necessary for them to interact with loefsys for their membership. Additionally, it is also possible that a user account is made for guests who need access to the site. This user model is used for both cases and the only difference in model values is that a member has a

created

The timestamp of the creation of this model.

Type:

datetime

modified

The timestamp of last modification of this model.

Type:

datetime

email

The email of the user, required to log in.

Type:

str

password

The password for this user.

Type:

str

last_login

the timestamp of the last login for this user.

Type:

datetime

is_superuser

Designated that this user has all permissions without explicit assignation.

Type:

bool

groups

The groups that this user belongs to.

Type:

QuerySet of LoefbijterGroup

user_permissions

The specific permissions for this user.

Type:

QuerySet of Permission

phone_number

The phone number of the user.

For members, a phone number is required, and it is recommended for guest accounts too. However, it is possible that no phone number is available for ex-members, so the field should take into account empty values too.

Type:

str

picture
Type:

ImageFieldFile

note

A note field that are only visible to active board members.

For guest accounts, a note can provide information for which purpose this account exists. For members, incidents can potentially be tracked.

Type:

str

user_upload_directory()

Return the user upload directory.

user_picture_upload_path(_)

Return the upload path for the user profile picture.

delete_profile_picture()

Delete the image file associated with the profile picture.

email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

phone_number

The descriptor for the phone number attribute on the model instance. Returns a PhoneNumber when accessed so you can do stuff like:

>>> instance.phone_number.as_international

Assigns a phone number object on assignment so you can do:

>>> instance.phone_number = PhoneNumber(...)

or,

>>> instance.phone_number = '+414204242'
picture

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

note

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

EMAIL_FIELD = 'email'
USERNAME_FIELD = 'email'
objects = <loefsys.users.models.user.UserManager object>
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

authorized_skippers

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

display_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

display_name_preference

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

eventregistration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

feedtoken

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_display_name_preference_display(*, field=<django.db.models.fields.PositiveSmallIntegerField: display_name_preference>)
get_next_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=False, **kwargs)
groupmembership_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

initials

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_superuser

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_login

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

logentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

member

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

modified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

nickname

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

organizer

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

reservee_user_reservation_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

skippers

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

userlog_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

userskippership_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.