class Contact(models.Model): user = models.OneToOneField(User) phone_number = us_models.PhoneNumberField() address = models.CharField(max_length=255) city = models.CharField(max_length=255) state = us_models.USStateField() zip_code = models.CharField(max_length=255) history = history_models.HistoricalRecords() class Meta: ordering = ('user__last_name', 'user__first_name') def __unicode__(self): return self.user.get_full_name() @property def first_name(self): return self.user.first_name @property def last_name(self): return self.user.last_name def get_full_name(self): return self.user.get_full_name()
class DonorAddress(models.Model): """Address associated with a ``Donor``""" address = models.CharField(max_length=255) city = models.CharField(max_length=20) state = us.USStateField() zipcode = models.CharField(max_length=10) def __unicode__(self): return "%(address)s, %(city)s, %(state)s, %(zipcode)s" % self.__dict__
class Employer(models.Model): name = models.CharField(max_length=30) email = models.EmailField(max_length=30) onCampus = models.BooleanField() address = models.CharField(max_length=64, blank=True) city = models.CharField(max_length=64, blank=True) state = us_models.USStateField(blank=True) zipCode = models.CharField(max_length=64, blank=True) phone = models.CharField(max_length=12, blank=True) designation = models.CharField(max_length=1, blank=True, choices=EMP_DESIGNATIONS) def __unicode__(self): return '%s\t%s' % (self.name, self.email) class Meta: ordering = ['name']
class AddressableCoordinateModel(CoordinateModel): address_0 = models.CharField(verbose_name='Address', max_length=255) address_1 = models.CharField( verbose_name='Apt, Suite, Bldg', blank=True, null=True, max_length=100 ) city = models.CharField(max_length=100) state = lfus_models.USStateField() zipcode = models.CharField(max_length=10) def get_current_location(self): return u'%s%s %s, %s %s' % ( self.address_0, ' '+self.address_1 if self.address_1 else '', self.city, self.state, self.zipcode ) class Meta: abstract = True
class Person(TimeStampedModel): """ A person. With name, `tiger.Company`, address, and email """ first_name = models.CharField(verbose_name="First Name", max_length=42) middle_name = models.CharField(verbose_name="Middle Name", max_length=42, blank=True) last_name = models.CharField(verbose_name="Last Name", max_length=42) company = models.ForeignKey('Company', verbose_name="Company", related_name="person_worksfor_company", blank=True, null=True) addr_1 = models.CharField(verbose_name="Address Line 1", max_length=42, blank=True) addr_2 = models.CharField(verbose_name="Address Line 2", max_length=42, blank=True) city = models.CharField(verbose_name="City", max_length=42) state = us_models.USStateField(verbose_name="State") zip_code = models.CharField(verbose_name="Zip Code", max_length=10) email = models.EmailField(verbose_name="Email Address") user = models.ForeignKey(User, unique=True, verbose_name="User", blank=True, null=True) def __unicode__(self): return self.full_name() class Meta: verbose_name_plural = "People" @models.permalink def get_absolute_url(self): return ('profiles_profile_detail' (), {'username': self.user.username}) def full_name(self): return "%s %s %s" % (self.first_name, self.middle_name and ('%s.' % self.middle_name) or '', self.last_name)
class City(models.Model): """City model""" city = models.CharField(_('city'), max_length=47) state = us_models.USStateField(_('state')) slug = AutoSlugField(_('slug'), editable=False, populate_from=lambda instance: '-'.join( (instance.city, instance.state))) class Meta: verbose_name = _('city') verbose_name_plural = _('cities') unique_together = (('city', 'state')) def __unicode__(self): return u'%s, %s' % (self.city, self.state) @permalink def get_absolute_url(self): return 'place_city_detail', None, {'slug': self.slug}
class Location(models.Model): city = models.CharField(max_length=64) state = us_models.USStateField() def __unicode__(self): return "%s, %s" % (self.city, self.state)