Features: 1) Add avatar_url property to User model.
Fixes: 1) Restore correct imports order in `engine/vibes_auth/models.py`. Extra: 1) Adjust formatting and grouping for clarity in imports section.
This commit is contained in:
parent
9fe433221a
commit
d03b6b0ec9
1 changed files with 16 additions and 11 deletions
|
|
@ -6,20 +6,21 @@ from django.contrib.auth.models import Group as BaseGroup
|
|||
from django.core.cache import cache
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models import (
|
||||
BooleanField,
|
||||
CharField,
|
||||
EmailField,
|
||||
ImageField,
|
||||
JSONField,
|
||||
UUIDField,
|
||||
ForeignKey,
|
||||
TextField,
|
||||
DateTimeField,
|
||||
Index,
|
||||
CASCADE,
|
||||
SET_NULL,
|
||||
BooleanField,
|
||||
CharField,
|
||||
DateTimeField,
|
||||
EmailField,
|
||||
ForeignKey,
|
||||
ImageField,
|
||||
Index,
|
||||
JSONField,
|
||||
TextField,
|
||||
UUIDField,
|
||||
)
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework_simplejwt.token_blacklist.models import (
|
||||
BlacklistedToken as BaseBlacklistedToken,
|
||||
|
|
@ -29,10 +30,10 @@ from rest_framework_simplejwt.token_blacklist.models import (
|
|||
)
|
||||
|
||||
from engine.core.abstract import NiceModel
|
||||
from engine.payments.models import Balance
|
||||
from engine.vibes_auth.choices import SenderType, ThreadStatus
|
||||
from engine.vibes_auth.managers import UserManager
|
||||
from engine.vibes_auth.validators import validate_phone_number
|
||||
from engine.payments.models import Balance
|
||||
|
||||
|
||||
class User(AbstractUser, NiceModel): # type: ignore [django-manager-missing]
|
||||
|
|
@ -98,6 +99,10 @@ class User(AbstractUser, NiceModel): # type: ignore [django-manager-missing]
|
|||
# noinspection PyClassVar
|
||||
objects = UserManager() # type: ignore [misc, assignment]
|
||||
|
||||
@cached_property
|
||||
def avatar_url(self):
|
||||
return self.avatar.url
|
||||
|
||||
def add_to_recently_viewed(self, product_uuid):
|
||||
recently_viewed = self.recently_viewed
|
||||
if product_uuid not in recently_viewed:
|
||||
|
|
|
|||
Loading…
Reference in a new issue