from django.contrib.auth.models import User from django.utils.translation import ugettext as _ from django.db import models from . import constants class StoreProfile(models.Model): user = models.OneToOneField( User, unique=True, verbose_name=_("user"), related_name="my_profile" ) company = models.CharField(max_length=30, blank=True, null=True) address1 = models.CharField(max_length=30) address2 = models.CharField(max_length=30) city = models.CharField(max_length=30) region = models.CharField(max_length=30, choices=constants.STATE_CHOICES) phone = models.CharField(max_length=30) country = models.CharField(max_length=30, choices=constants.COUNTRIES) country_other = models.CharField(max_length=30) postal_code = models.CharField(max_length=30) plus_four = models.CharField(max_length=4) @property def secondary_address(self): from accounts.profile import get_profile_secondary_address return get_profile_secondary_address(self.user) class SecondaryProfileAddress(models.Model): """ Users can have multiple addresses """ profile = models.ForeignKey(StoreProfile) address_from = models.DateField(blank=True, null=True) address_to = models.DateField(blank=True, null=True) company = models.CharField(max_length=30, blank=True, null=True) first_name = models.CharField(max_length=30, blank=True, null=True) last_name = models.CharField(max_length=30, blank=True, null=True) address1 = models.CharField(max_length=30, blank=True, null=True) address2 = models.CharField(max_length=30, blank=True, null=True) city = models.CharField(max_length=30, blank=True, null=True) region = models.CharField( max_length=30, choices=constants.STATE_CHOICES, blank=True, null=True ) phone = models.CharField(max_length=30, blank=True, null=True) country = models.CharField( max_length=30, choices=constants.COUNTRIES, blank=True, null=True ) country_other = models.CharField(max_length=30, blank=True, null=True) postal_code = models.CharField(max_length=30, blank=True, null=True) plus_four = models.CharField(max_length=4, blank=True, null=True) email = models.CharField(max_length=30, blank=True, null=True)