32 lines
947 B
Python
32 lines
947 B
Python
|
import datetime
|
||
|
|
||
|
from django.db import models
|
||
|
|
||
|
from accounts.models import UserAccount
|
||
|
|
||
|
# Create your models here.
|
||
|
|
||
|
|
||
|
class UserProfile(models.Model):
|
||
|
"""Model definition for UserProfile."""
|
||
|
# from order.models import Address
|
||
|
user = models.OneToOneField(UserAccount, on_delete=models.CASCADE)
|
||
|
avatar = models.ImageField(upload_to='avatar/', null=True, blank=True)
|
||
|
phone_number = models.CharField(max_length=100, null=True, blank=True)
|
||
|
|
||
|
class Meta:
|
||
|
"""Meta definition for UserProfile."""
|
||
|
|
||
|
verbose_name = 'UserProfile'
|
||
|
verbose_name_plural = 'UserProfiles'
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.user.email
|
||
|
|
||
|
def get_shipping_address_data(self):
|
||
|
return None if not self.shipping_address else self.get_serialized_data(self.shipping_address)
|
||
|
|
||
|
def get_billing_address_data(self):
|
||
|
return None if not self.billing_address else self.get_serialized_data(self.billing_address)\
|
||
|
|