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
+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(
{