feat: added patch promocode, promocode stat, user signup/signin, user profile get/patch, user feed

also bug fixes and improvements
This commit is contained in:
ITQ
2025-01-23 21:40:34 +03:00
parent 2c10be8cf2
commit b7d7334fe5
21 changed files with 565 additions and 98 deletions
@@ -1,4 +1,4 @@
# Generated by Django 5.1.5 on 2025-01-21 11:05
# Generated by Django 5.1.5 on 2025-01-23 17:54
import django.core.validators
import django_countries.fields
@@ -24,6 +24,7 @@ class Migration(migrations.Migration):
('avatar_url', models.URLField(blank=True, max_length=350, null=True)),
('age', models.PositiveSmallIntegerField(validators=[django.core.validators.MaxValueValidator(100)])),
('country', django_countries.fields.CountryField(max_length=2)),
('country_raw', models.CharField(max_length=2)),
('password', models.CharField(max_length=60, validators=[django.core.validators.RegexValidator('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$')])),
('token_version', models.BigIntegerField(default=0)),
],
+11
View File
@@ -2,6 +2,7 @@ from datetime import timedelta
import jwt
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import (
MaxValueValidator,
MinLengthValidator,
@@ -28,6 +29,7 @@ class User(BaseModel):
avatar_url = models.URLField(max_length=350, blank=True, null=True)
age = models.PositiveSmallIntegerField(validators=[MaxValueValidator(100)])
country = CountryField(max_length=2)
country_raw = models.CharField(max_length=2)
password = models.CharField(
max_length=60,
validators=[
@@ -41,6 +43,15 @@ class User(BaseModel):
def __str__(self) -> str:
return f"{self.surname} {self.name}"
def clean(self) -> None:
super().clean()
if self.avatar_url == "":
err = {
"avatar_url": "Field cannot be blank.",
}
raise ValidationError(err)
def generate_token(self) -> str:
return jwt.encode(
{