2020-04-13 18:03:01 +00:00
|
|
|
from polymorphic.models import PolymorphicModel
|
|
|
|
from phonenumber_field.modelfields import PhoneNumberField
|
|
|
|
|
2020-04-15 20:56:04 +00:00
|
|
|
from django.db.models import OneToOneField, CASCADE, CharField, ImageField
|
2020-04-13 18:03:01 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
|
2020-04-18 13:02:41 +00:00
|
|
|
from core.helpers.files import generate_storage_filename
|
|
|
|
|
2020-04-13 18:03:01 +00:00
|
|
|
class Profile(PolymorphicModel):
|
|
|
|
user = OneToOneField(get_user_model(), CASCADE)
|
|
|
|
mobile = PhoneNumberField(blank=True)
|
|
|
|
|
|
|
|
class AdminProfile(Profile):
|
2020-04-18 13:02:41 +00:00
|
|
|
role = CharField(max_length=255)
|
|
|
|
image = ImageField(null=True, blank=True, upload_to=generate_storage_filename)
|
|
|
|
display_name = CharField("Internal Display Name", max_length=255, null=True, blank=True)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_internal_name(self):
|
|
|
|
return self.display_name if self.display_name else self.user.get_full_name
|