models.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from django.contrib.auth.models import User
  2. from django.utils.translation import ugettext as _
  3. from django.db import models
  4. from . import constants
  5. class StoreProfile(models.Model):
  6. user = models.OneToOneField(
  7. User, unique=True, verbose_name=_('user'), related_name='my_profile')
  8. company = models.CharField(max_length=30, blank=True, null=True)
  9. address1 = models.CharField(max_length=30)
  10. address2 = models.CharField(max_length=30)
  11. city = models.CharField(max_length=30)
  12. region = models.CharField(max_length=30, choices=constants.STATE_CHOICES)
  13. phone = models.CharField(max_length=30)
  14. country = models.CharField(max_length=30, choices=constants.COUNTRIES)
  15. country_other = models.CharField(max_length=30)
  16. postal_code = models.CharField(max_length=30)
  17. plus_four = models.CharField(max_length=4)
  18. @property
  19. def secondary_address(self):
  20. from accounts.profile import get_profile_secondary_address
  21. return get_profile_secondary_address(self.user)
  22. class SecondaryProfileAddress(models.Model):
  23. """ Users can have multiple addresses """
  24. profile = models.ForeignKey(StoreProfile)
  25. address_from = models.DateField(blank=True, null=True)
  26. address_to = models.DateField(blank=True, null=True)
  27. company = models.CharField(max_length=30, blank=True, null=True)
  28. first_name = models.CharField(max_length=30, blank=True, null=True)
  29. last_name = models.CharField(max_length=30, blank=True, null=True)
  30. address1 = models.CharField(max_length=30, blank=True, null=True)
  31. address2 = models.CharField(max_length=30, blank=True, null=True)
  32. city = models.CharField(max_length=30, blank=True, null=True)
  33. region = models.CharField(max_length=30, choices=constants.STATE_CHOICES,
  34. blank=True, null=True)
  35. phone = models.CharField(max_length=30, blank=True, null=True)
  36. country = models.CharField(max_length=30, choices=constants.COUNTRIES,
  37. blank=True, null=True)
  38. country_other = models.CharField(max_length=30, blank=True, null=True)
  39. postal_code = models.CharField(max_length=30, blank=True, null=True)
  40. plus_four = models.CharField(max_length=4, blank=True, null=True)
  41. email = models.CharField(max_length=30, blank=True, null=True)