Users Apps

class apps.users.models.ActivationCode(*args, **kwargs)[source]

Bases: Model

Activation Code Model, utilized to retain an activation code associated with a user in the event of password or email change/reset.

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

  • uid (CharField) – User ID in base64

  • email (EmailField) – Email. Used only in case of email changing confirmation

  • code (CharField) – Activation/confirmation code

  • expiration_date (DateTimeField) – Expiration date of activation code

Relationship fields:

Parameters:

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

class CodeTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: TextChoices

EMAIL = 'email'
PASSWORD = 'password'
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

code

Type: CharField

Activation/confirmation code

email

Type: EmailField

Email. Used only in case of email changing confirmation

expiration_date

Type: DateTimeField

Expiration date of activation code

get_next_by_expiration_date(*, field=<django.db.models.DateTimeField: expiration_date>, is_next=True, **kwargs)

Finds next instance based on expiration_date. See get_next_by_FOO() for more information.

get_previous_by_expiration_date(*, field=<django.db.models.DateTimeField: expiration_date>, is_next=False, **kwargs)

Finds previous instance based on expiration_date. See get_previous_by_FOO() for more information.

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
uid

Type: CharField

User ID in base64

user

Type: ForeignKey to User

User (related name: activation_codes)

user_id

Internal field, use user instead.

class apps.users.models.Category(*args, **kwargs)[source]

Bases: Model

Content Category Model, utilized both during user registration and content creation.

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

icon

Type: FileField

Icon

id

Type: BigAutoField

Primary key: ID

name

Type: CharField

Name of category

objects = <django.db.models.Manager object>
post_set

Type: Reverse ManyToManyField from Post

All posts of this Category (related name of categories)

user_set

Type: Reverse ManyToManyField from User

All users of this Category (related name of interests)

class apps.users.models.Profile(*args, **kwargs)[source]

Bases: Model

User Profile Model encompasses all supplementary user information.

Parameters:

Relationship fields:

Parameters:

user (OneToOneField to User) – User (related name: profile)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

avatar

Type: ImageField

Avatar

birthdate

Type: DateField

Date of Birth

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
user

Type: OneToOneField to User

User (related name: profile)

user_id

Internal field, use user instead.

class apps.users.models.User(*args, **kwargs)[source]

Bases: AbstractUser

Primary user model that inherits from django AbstractUser Main fields are email (used as login), username, password

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

REQUIRED_FIELDS = ['username']
USERNAME_FIELD = 'email'
activation_codes

Type: Reverse ForeignKey from ActivationCode

All activation codes of this user (related name of user)

bio

Type: TextField

Bio

comments

Type: Reverse ForeignKey from Comment

All comments of this user (related name of author)

date_joined

Type: DateTimeField

Date joined

email

Type: EmailField

Email

favorite_posts

Type: Reverse ForeignKey from Favorite

All favorite posts of this user (related name of author)

first_name

Type: CharField

First name

followers

Type: Reverse ManyToManyField from User

All followers of this user (related name of following)

following

Type: ManyToManyField to User

Following (related name: followers)

get_next_by_date_joined(*, field=<django.db.models.DateTimeField: date_joined>, is_next=True, **kwargs)

Finds next instance based on date_joined. See get_next_by_FOO() for more information.

get_previous_by_date_joined(*, field=<django.db.models.DateTimeField: date_joined>, is_next=False, **kwargs)

Finds previous instance based on date_joined. See get_previous_by_FOO() for more information.

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

interests

Type: ManyToManyField to Category

List of user’s interests (related name: user)

is_active

Type: BooleanField

Is active

is_deleted

Type: BooleanField

Is user deleted

is_passed_onboarding

Type: BooleanField

Is user passed onboarding

is_staff

Type: BooleanField

Staff status. Designates whether the user can log into this admin site.

is_superuser

Type: BooleanField

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

last_login

Type: DateTimeField

Last login

last_name

Type: CharField

Last name

liked_posts

Type: Reverse ForeignKey from Like

All liked posts of this user (related name of author)

property limited_following
logentry_set

Type: Reverse ForeignKey from LogEntry

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

notifications

Type: Reverse ForeignKey from Notification

All notifications of this user (related name of receiver)

objects: NotDeletedManager = <apps.users.managers.NotDeletedManager object>
password

Type: CharField

Password

posts

Type: Reverse ForeignKey from Post

All posts of this user (related name of author)

profile

Type: Reverse OneToOneField from Profile

The profile of this user (related name of user)

requests_quantity

Type: PositiveSmallIntegerField

Requests quantity. Needs for salt generation for uid

sender

Type: Reverse ForeignKey from Notification

All sender of this user (related name of sender)

user_permissions

Type: ManyToManyField to Permission

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

username

Type: CharField

Username. Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.

viewed_posts

Type: Reverse ForeignKey from View

All viewed posts of this user (related name of author)

class apps.users.admin.AdminCategory(model, admin_site)[source]

Bases: RolePermissionsModelAdmin

property media
class apps.users.admin.CustomUserAdmin(model, admin_site)[source]

Bases: RolePermissionsModelAdmin, UserAdmin

add_fieldsets = ((None, {'classes': ('wide',), 'fields': ('username', 'email', 'password1', 'password2')}),)
display_roles(obj) str[source]
inlines = [<class 'apps.users.admin.ProfileInline'>]
list_display = ('username', 'email', 'first_name', 'last_name', 'display_roles', 'is_staff')
property media
search_fields = ['username', 'email']
class apps.users.admin.ProfileInline(parent_model, admin_site)[source]

Bases: StackedInline

max_num = 1
property media
min_num = 1
model

alias of Profile

apps.users.signals.create_user(sender, instance: User, created: bool, **kwargs: Dict)[source]

Post signal after creation user :param sender: User model :param instance: User model :param created: check is object created :param kwargs: other params :return: None

apps.users.signals.delete_post(sender, instance, **kwargs)[source]
apps.users.signals.index_user(sender, instance, **kwargs)[source]
apps.users.signals.make_user_staff(sender, instance, **kwargs)[source]

Assigns staff user content manager role

class apps.users.validators.AgeValidator(*args, **kwargs)[source]

Bases: object

__init__()[source]
code = 'age_validation_error'
deconstruct()

Return a 3-tuple of class import path, positional arguments, and keyword arguments.

messages = {'age_validation_error': 'The user must be over 12 years old.', 'min_age_validation_error': 'Year of birth cannot be earlier than 1900.'}
min_year = 1900
class apps.users.validators.SVGValidator(*args, **kwargs)[source]

Bases: object

code = 'invalid_svg'
deconstruct()

Return a 3-tuple of class import path, positional arguments, and keyword arguments.

message = 'This file is not a valid SVG.'
class apps.users.roles.ContentModerator[source]

Bases: AbstractUserRole

Role with basic admin permissions

available_permissions = {'change_comment': True, 'change_post': True, 'view_all_models': True}
class apps.users.managers.NotDeletedManager(*args, **kwargs)[source]

Bases: UserManager

Manager that uses the NotDeletedQuerySet to filter out deleted objects.

create_superuser(username, email=None, password=None, **extra_fields)[source]
get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class apps.users.managers.NotDeletedQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: QuerySet

QuerySet that filters out objects which are marked as deleted.

alive()[source]
class apps.users.documents.UserDocument(related_instance_to_ignore=None, **kwargs)[source]

Bases: DocType

class Django[source]

Bases: object

fields = ['username', 'first_name', 'last_name']
model

alias of User

class Index[source]

Bases: object

name = 'users'
django = {'model': <class 'apps.users.models.User'>, 'ignore_signals'...}
class apps.users.apps.UsersConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.users'
ready() None[source]

Override this method in subclasses to run code when Django starts.