mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 01:37:11 +00:00
add created_at to user model
This commit is contained in:
@@ -22,4 +22,4 @@ class LoginSchema(ModelSchema):
|
|||||||
class UserSchema(ModelSchema):
|
class UserSchema(ModelSchema):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ["id", "email", "username"]
|
fields = ["id", "email", "username", "created_at",]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from datetime import datetime
|
||||||
from http import HTTPStatus as status
|
from http import HTTPStatus as status
|
||||||
|
|
||||||
from django.contrib.auth.hashers import check_password, make_password
|
from django.contrib.auth.hashers import check_password, make_password
|
||||||
@@ -35,6 +36,7 @@ router = Router(tags=["user"])
|
|||||||
def sign_up(request, data: RegisterSchema):
|
def sign_up(request, data: RegisterSchema):
|
||||||
user = User(**data.dict(exclude={"password"}))
|
user = User(**data.dict(exclude={"password"}))
|
||||||
user.password = make_password(data.password)
|
user.password = make_password(data.password)
|
||||||
|
user.created_at = datetime.now()
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
token = BearerAuth.generate_jwt(user)
|
token = BearerAuth.generate_jwt(user)
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-03-02 09:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('user', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='created_at',
|
||||||
|
field=models.DateTimeField(auto_now=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -14,6 +14,8 @@ class User(BaseModel):
|
|||||||
username = models.SlugField(unique=True, verbose_name="юзернейм")
|
username = models.SlugField(unique=True, verbose_name="юзернейм")
|
||||||
password = models.TextField(verbose_name="пароль")
|
password = models.TextField(verbose_name="пароль")
|
||||||
|
|
||||||
|
created_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def make_password(password: str):
|
def make_password(password: str):
|
||||||
return make_password(password)
|
return make_password(password)
|
||||||
|
|||||||
Reference in New Issue
Block a user