2020-04-13 18:03:01 +00:00
|
|
|
from polymorphic.models import PolymorphicModel
|
|
|
|
from phonenumber_field.modelfields import PhoneNumberField
|
2020-05-27 13:06:38 +00:00
|
|
|
from internationalflavor.vat_number.models import VATNumberField
|
|
|
|
from django_countries.fields import CountryField
|
2020-04-13 18:03:01 +00:00
|
|
|
|
2020-05-27 13:06:38 +00:00
|
|
|
from django.db.models import OneToOneField, CASCADE, ImageField, Model, ForeignKey, SET_DEFAULT, ManyToManyField, DateTimeField, TextField
|
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-05-27 13:06:38 +00:00
|
|
|
from core.models.local import Currency
|
|
|
|
from core.models.brands import Brand
|
|
|
|
from core.fields.base import LongCharField
|
|
|
|
|
|
|
|
class ClientGroup(Model):
|
|
|
|
name = LongCharField()
|
2020-04-18 13:02:41 +00:00
|
|
|
|
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-05-27 13:06:38 +00:00
|
|
|
role = LongCharField()
|
2020-04-18 13:02:41 +00:00
|
|
|
image = ImageField(null=True, blank=True, upload_to=generate_storage_filename)
|
2020-05-27 13:06:38 +00:00
|
|
|
display_name = LongCharField("Internal Display Name", null=True, blank=True)
|
2020-04-18 13:02:41 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def get_internal_name(self):
|
2020-05-27 13:06:38 +00:00
|
|
|
return self.display_name if self.display_name else self.user.get_full_name
|
|
|
|
|
|
|
|
class ClientProfile(Profile):
|
|
|
|
company = LongCharField()
|
|
|
|
address1 = LongCharField()
|
|
|
|
address2 = LongCharField()
|
|
|
|
zip = LongCharField()
|
|
|
|
city = LongCharField()
|
|
|
|
state = LongCharField()
|
|
|
|
country = CountryField()
|
|
|
|
vat_id = VATNumberField()
|
|
|
|
company_id = LongCharField()
|
|
|
|
default_currency = ForeignKey(Currency, on_delete=SET_DEFAULT, default=Currency.get_base)
|
|
|
|
client_groups = ManyToManyField(ClientGroup)
|
|
|
|
brands = ManyToManyField(Brand)
|
|
|
|
marketing_opt_in = DateTimeField(null=True)
|
|
|
|
pgp_key = TextField(null=True)
|
|
|
|
main_client = ForeignKey("self", null=True, on_delete=SET_DEFAULT, default=None)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_nda(self):
|
|
|
|
return None
|