mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 00:27:11 +00:00
11494d42ff
[body] [footer(s)]
33 lines
908 B
Python
33 lines
908 B
Python
from django.contrib.auth.hashers import check_password, make_password
|
|
from django.db import models
|
|
|
|
from apps.core.models import BaseModel
|
|
|
|
|
|
class UserRole(models.Choices):
|
|
STUDENT = "student"
|
|
METODIST = "metodist"
|
|
|
|
|
|
class User(BaseModel):
|
|
email = models.EmailField(unique=True, verbose_name="почта")
|
|
username = models.SlugField(unique=True, verbose_name="юзернейм")
|
|
password = models.TextField(verbose_name="пароль")
|
|
|
|
def make_password(self):
|
|
return make_password(self.password)
|
|
|
|
def check_password(self, password):
|
|
return check_password(self.password, password)
|
|
|
|
status = models.CharField(
|
|
max_length=10, choices=UserRole, default="student"
|
|
)
|
|
|
|
def __str__(self) -> str:
|
|
return self.username
|
|
|
|
class Meta:
|
|
verbose_name = "пользователь"
|
|
verbose_name_plural = "пользователи"
|