示例#1
0
class PoliticianMetadata(models.Model):
    entity = models.ForeignKey(Entity,
                               related_name='politician_metadata_by_cycle',
                               null=False,
                               db_index=True)

    cycle = models.PositiveSmallIntegerField()

    state = USStateField(blank=True, null=True)
    state_held = USStateField(blank=True, null=True)
    district = models.CharField(max_length=8, blank=True, null=True)
    district_held = models.CharField(max_length=8, blank=True, null=True)
    party = models.CharField(max_length=64, blank=True, null=True)
    seat = models.CharField(max_length=64, blank=True, null=True)
    seat_held = models.CharField(max_length=64, blank=True, null=True)
    seat_status = models.CharField(max_length=10,
                                   blank=True,
                                   choices=(('incumbent', 'Incumbent'),
                                            ('challenger',
                                             'Challenger'), ('open', 'Open')))
    seat_result = models.CharField(max_length=4,
                                   blank=True,
                                   choices=(('win', 'Win'), ('loss', 'Loss')))

    class Meta:
        db_table = 'matchbox_politicianmetadata'
示例#2
0
class PoliticianMetadataLatest(models.Model):
    entity = models.OneToOneField(
        Entity,
        related_name='politician_metadata_for_latest_cycle',
        null=False,
        primary_key=True,
        on_delete=models.DO_NOTHING)

    cycle = models.PositiveSmallIntegerField()

    state = USStateField(blank=True, null=True)
    state_held = USStateField(blank=True, null=True)
    district = models.CharField(max_length=8, blank=True, null=True)
    district_held = models.CharField(max_length=8, blank=True, null=True)
    party = models.CharField(max_length=64, blank=True, null=True)
    seat = models.CharField(max_length=64, blank=True, null=True)
    seat_held = models.CharField(max_length=64, blank=True, null=True)
    seat_status = models.CharField(max_length=10,
                                   blank=True,
                                   choices=(('incumbent', 'Incumbent'),
                                            ('challenger',
                                             'Challenger'), ('open', 'Open')))
    seat_result = models.CharField(max_length=4,
                                   blank=True,
                                   choices=(('win', 'Win'), ('loss', 'Loss')))

    class Meta:
        db_table = 'politician_metadata_latest_cycle_view'
        managed = False
示例#3
0
class UserProfile(models.Model):
    home_address_street = models.CharField(blank=True, max_length = 255)
    home_address_city = models.CharField(blank=True, max_length = 50)
    home_address_state = USStateField(blank=True)
    home_address_zip = models.CharField(blank=True, max_length = 10)
    home_phone_number = PhoneNumberField(blank=True)
    mobile_phone_number = PhoneNumberField(blank=True)
    notes = models.TextField(blank=True)
    rank = models.TextField(blank=True)
    membership_type = models.TextField(blank=True)
    committee = models.TextField(blank=True)
    birth_day = models.DateField(null=True, blank=True)
    aaco_riding_db = models.BooleanField('AACO Riding Database', blank=True)
    badge_number = models.CharField(blank=True, max_length = 10)
    active_years_dues = models.BooleanField('Active year\'s dues paid', blank=True)
    life_insurance = models.BooleanField(blank=True)
    ssn = models.CharField('SSN', blank=True, max_length = 11)
    sex = models.CharField(blank=True, max_length = 6)
    race = models.CharField(blank=True, max_length = 20)
    drivers_license_number = models.CharField(blank=True, max_length = 50)
    drivers_license_state = USStateField(blank=True)
    drivers_license_class = models.CharField(blank=True, max_length = 25)
    drivers_license_expiration = models.DateField(null=True, blank=True)
    administrative = models.BooleanField(blank=True)
    membership_date = models.DateField(null=True, blank=True)
    user = models.ForeignKey(User, unique=True)
    
    def __unicode__(self):
        return self.user.username
    
    class Meta:
        permissions = (
            ("can_view_private", "Can view protected information"),
        )
示例#4
0
class USPlace(models.Model):
    state = USStateField(blank=True)
    state_req = USStateField()
    state_default = USStateField(default="CA", blank=True)
    name = models.CharField(max_length=20)

    class Meta:
        app_label = 'localflavor'
示例#5
0
class Address(MildModeratedModel):
    address1 = models.CharField(blank=True, null=True, max_length=100)
    address2 = models.CharField(blank=True, null=True, max_length=100)
    city = models.CharField(max_length=50)
    state = USStateField()
    zipcode = models.CharField(blank=True, null=True, max_length=10)
    lat = models.FloatField(blank=True, null=True)
    lng = models.FloatField(blank=True, null=True)

    class Meta:
        verbose_name_plural = u"Addresses"
        unique_together = ('address1', 'address2', 'city', 'state', 'zipcode')

    def _combined_address(self):
        address_bits = [self.city, self. state]
        for street in (self.address2, self.address1):
            if street != '':
                address_bits.insert(0, street)
        return u'{0} {1}'.format(u', '.join(address_bits), self.zipcode or u'')

    def combined_address():
        doc = "The combined_address property."

        def fget(self):
            return self._combined_address()
        return locals()
    combined_address = property(**combined_address())

    def __unicode__(self):
        return self.combined_address
示例#6
0
class Guardian(models.Model):
    user = models.ForeignKey(UserProfile)
    relationship = models.CharField(max_length=11,
                                    choices=relationship_choices)
    salute = models.CharField(max_length=4, choices=title_choices, blank=True)
    first = models.CharField(max_length=30)
    middle = models.CharField(max_length=30, blank=True)
    last = models.CharField(max_length=50)
    street_address = models.CharField(max_length=70, blank=True)
    city = models.CharField(max_length=30, blank=True)
    state = USStateField(
        default='GA',
        blank=True,
    )
    zip = models.CharField(max_length=5, blank=True)
    primary_phone = PhoneNumberField()
    secondary_phone = PhoneNumberField(blank=True)  # help_text='(optional)')
    tertiary_phone = PhoneNumberField(blank=True)
    email = models.EmailField(blank=True)
    employer = models.CharField(max_length=100, blank=True)
    title = models.CharField(max_length=50, blank=True)

    church = models.CharField(max_length=70)
    pastor = models.CharField(max_length=70)
    church_phone_number = PhoneNumberField(verbose_name="Church's phone")

    def students(self):
        ss = Student.objects.filter(user=self.user)
        string = ''
        for s in ss:
            string += s.name() + ', '
        return string

    def __unicode__(self):
        return self.first + ' ' + self.last
示例#7
0
class FamilyMember(models.Model):
    user = models.ForeignKey(UserProfile)
    title = models.CharField(
        max_length=4,
        choices=title_choices,
        blank=True,
    )
    name = models.CharField(max_length=70, )
    relationship = models.CharField(
        max_length=11,
        choices=relationship_choices,
    )
    phone = PhoneNumberField(blank=True, )
    email = models.EmailField(blank=True, )
    street_address = models.CharField(max_length=70, blank=True)
    city = models.CharField(max_length=50, blank=True)
    state = USStateField(
        default='GA',
        blank=True,
    )
    zip = models.CharField(max_length=5, blank=True)

    def students(self):
        return studs(self)

    def __unicode__(self):
        return "%s %s" % (self.title, self.name)
示例#8
0
class Person(models.Model):
    SHIRT_SIZES = ((u'S', u'Small'), (u'M', u'Medium'), (u'L', u'Large'))
    first_name = models.CharField("person's first name", max_length=30)
    last_name = models.CharField("person's last name", max_length=30)
    birth_date = models.DateField()
    address = models.CharField(max_length=100)
    city = models.CharField(max_length=50)
    state = USStateField()  # Yes, this is America-centric...
    shirt_size = models.CharField(max_length=2, choices=SHIRT_SIZES)

    def __unicode__(self):
        return self.first_name

    def baby_boomer_status(self):
        "Return the person's baby-boomer status."
        import datetime
        if datetime.date(1945, 8, 1) <= self.birth_date <= datetime.date(
                1964, 12, 31):
            return "Baby boomer"
        if self.birth_date < datetime.date(1945, 8, 1):
            return "Post-boomer"
        return "Post-boomer"

    def is_midwestern(self):
        "Return True if this person is from the Midwest."
        return self.state in ('IL', 'WI', 'MI', 'IN', 'OH', 'IA', 'MO')

    def _get_full_name(self):
        "Returns the person's full name."
        return '%s %s' % (self.first_name, self.last_name)

    full_name = property(_get_full_name)
 def setUp(self):
   Business.objects.create(name="Test Business 1", \
     address_1="123 Test Address 1",               \
     address_2="Suite 420",                        \
     city="Portland"                               \
     state=USStateField.clean('OR')                \
     zip="97214")
示例#10
0
文件: models.py 项目: shacker/djcc
class Address(models.Model):
    """
    People's Addresses - they can have more than one.
    """

    profile = models.ForeignKey(Profile)
    address_type = models.IntegerField(max_length=2,
                                       choices=constants.ADDRESS_TYPE_CHOICES)
    street_1 = models.CharField(max_length=200, blank=True, null=True)
    street_2 = models.CharField(max_length=200, blank=True, null=True)
    street_3 = models.CharField(max_length=200, blank=True, null=True)
    city = models.CharField(max_length=200)
    state = USStateField(blank=True, null=True)
    state_other = models.CharField(
        max_length=384,
        blank=True,
        null=True,
        help_text='Useful for international addresses.')
    postal_code = models.CharField(max_length=50, blank=True, null=True)
    country = models.ForeignKey(Country, blank=True, null=True)
    display = models.BooleanField(
        default=True, help_text="Display this address on my profile page")

    def __unicode__(self):
        return "%s %s, %s" % (self.street_1, self.city, self.state)

    class Meta:
        verbose_name = "Address"
        verbose_name_plural = "Addresses"

    def get_form_name(self):
        return "%sForm" % self._meta.module_name.title()
示例#11
0
class Town(models.Model):
    name=models.CharField(_('name'), max_length=100)
    state=USStateField(_('state'))
    zipcode=ZipCodeField(_('zip'), max_length=5)

    def __unicode__(self):
        return u'%s, %s %s' % (self.name, self.state, self.zipcode)
示例#12
0
class Location(models.Model):
    name = models.CharField(max_length=100)
    url = models.URLField(max_length=500, blank=True)
    phone = PhoneNumberField()
    street_address = models.CharField(max_length=200)
    city = models.CharField(max_length=100)
    state = USStateField()
    zip = models.CharField(max_length=5)
    lat = models.FloatField(editable=False)
    long = models.FloatField(editable=False)

    def __unicode__(self):
        return self.name

    @property
    def latlong(self):
        return (self.lat, self.long)

    @property
    def location(self):
        return '%s %s, %s %s' % (self.street_address, self.city, self.state, self.zip)

    def save(self, *args, **kwargs):
        # Geocode the address and save the lattitude and longitude
        g = geocoders.Google()
        latlong = g.geocode(self.location)[1]
        self.lat = latlong[0]
        self.long = latlong[1]
        # Call the real save
        super(Location, self).save(*args, **kwargs)
示例#13
0
class Street(models.Model):
    street = models.CharField(max_length=255,
                              db_index=True)  # Always uppercase
    pretty_name = models.CharField(max_length=255)
    street_slug = models.SlugField()
    suffix = models.CharField(max_length=32, blank=True,
                              db_index=True)  # Always uppercase
    city = models.CharField(max_length=255, db_index=True)  # Always uppercase
    state = USStateField(db_index=True)  # Always uppercase

    class Meta:
        db_table = 'streets'

    def __unicode__(self):
        return self.pretty_name

    def url(self):
        if get_metro()['multiple_cities']:
            return '/streets/%s/%s/' % (self.city_object().slug,
                                        self.street_slug)
        else:
            return '/streets/%s/' % self.street_slug

    def city_object(self):
        return City.from_norm_name(self.city)
示例#14
0
class Person(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    birth_date = models.DateField()
    address = models.CharField(max_length=100)
    city = models.CharField(max_length=50)
    state = USStateField()  # Yes, this is U.S.-centric...

    def baby_boomer_status(self):
        """Returns the person's baby-boomer status."""
        import datetime
        if datetime.date(1945, 8, 1) <= self.birth_date <= datetime.date(
                1964, 12, 31):
            return "Baby boomer"
        if self.birth_date < datetime.date(1945, 8, 1):
            return "Pre-boomer"
        return "Post-boomer"

    def is_midwestern(self):
        """Returns True if this person is from the Midwest."""
        return self.state in ('IL', 'WI', 'MI', 'IN', 'OH', 'IA', 'MO')

    def _get_full_name(self):
        """Returns the person's full name."""
        return u'%s %s' % (self.first_name, self.last_name)

    full_name = property(_get_full_name)
class TaxState(models.Model):
    shop = models.ForeignKey(Shop)
    state = USStateField()
    tax = models.DecimalField(max_digits=11, decimal_places=2)
    apply_tax_to_shipping = models.BooleanField(default=False)

    def __str__(self):
        return "%s > %s: $%s (apply_on_ship=%s)" % (self.shop, self.state, self.tax, self.apply_tax_to_shipping)
示例#16
0
class City(models.Model):
    name = models.CharField(max_length=50)
    state = USStateField()
    location = models.ForeignKey(Location)
    objects = models.GeoManager()

    def __unicode__(self):
        return self.name
示例#17
0
class Address(models.Model):
    address1 = models.CharField(max_length=128)
    address2 = models.CharField(max_length=128, blank=True)

    city = models.CharField(max_length=64)
    state = USStateField(choices=US_STATES)
    zip = models.CharField(max_length=5, blank=True)
    country = models.CharField(max_length=24, default='United States')
示例#18
0
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    receives_new_posting_notices = models.BooleanField(default=False)
    receives_newsletter = models.BooleanField(default=False)
    address = models.CharField(max_length=100, blank=True, default='')
    city = models.CharField(max_length=100, blank=True, default='')
    state = USStateField(blank=True, default='')
    zipcode = models.CharField(max_length=10, blank=True, default='')
    phone = PhoneNumberField(blank=True, default='')
示例#19
0
 def testBusinessProperties(self):
   """Verify business fields are set"""
   test_business = Business.objects.get(name="Test Business 1")
   self.assertEqual(testBusiness.address_1, "123 Test Address 1")
   self.assertEqual(testBusiness.address_2, "Suite 420")
   self.assertEqual(testBusiness.city, "Portland")
   self.assertEqual(testBusiness.state, USStateField.clean('OR'))
   self.assertEqual(testBusiness.zip, "97214")
   
示例#20
0
class Location(models.Model):
    id = models.IntegerField(primary_key=True)
    earmark = models.ForeignKey(Earmark)
    name = models.CharField(max_length=255)
    street = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    state = USStateField()

    def __str__(self):
        return '%s %s %s, %s' % (self.name, self.street, self.city, self.state)
示例#21
0
class UserProfile(models.Model):
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=_('user'),
                                related_name='user_profile')

    address = models.TextField(_('address'))
    city = models.CharField(_('city'), max_length=255)
    state = USStateField(_('state'))
    zipcode = models.CharField(_('zipcode'), max_length=255)
示例#22
0
class Actor(models.Model):
    """An Actor or Actress"""
    first_name = models.CharField(max_length=128)
    last_name = models.CharField(max_length=128)
    AGE_CHOICES = (
      (0, '1-6'),
      (1, '7-12'),
      (3, '13-18'),
      (4, '19-30'),
      (5, '31-45'),
      (6, '45+')
    )
    age_range = models.IntegerField(max_length=1, choices=AGE_CHOICES)
    height = models.CharField(max_length=128)
    size = models.CharField(max_length=128)
    union = models.CharField(max_length=128)
    special = models.TextField(blank=None)
    reference = models.TextField(blank=True, null=True)
    line1 = models.CharField(max_length = 128)
    line2 = models.CharField(max_length = 128, blank=True)
    city = models.CharField(max_length = 128)
    state = USStateField()
    zipcode = models.CharField(max_length=10)
    phone = PhoneNumberField()
    alt_phone = PhoneNumberField(blank=True)
    email = models.EmailField()
    image = models.ImageField(upload_to='actorpics', null=True, blank=True, default='actorpics/default.jpg')


    def __unicode__(self):
        return self.first_name+' '+self.last_name

    @models.permalink
    def get_absolute_url(self):
        return ('Actor', [self.id])
    
    def thumbnail_img_tag(self):
      SCALE = 0.25
      WIDTH = 640
      HEIGHT = 480
      return '<img src="'+self.image.url+'" height="'+str(SCALE*HEIGHT)+'" width="'+str(SCALE*WIDTH)+'" />'
    thumbnail_img_tag.allow_tags = True
    
    def most_recent_audition_tag(self):
      auditions = self.audition_set.all()
      # If this actor has auditions
      if auditions.count():
        # Get most recent
        mostRecentAudition = auditions.order_by('-date')[0]
      
        return '<div class="most_recent_audition"><div class="most_recent_audition_header">'+mostRecentAudition.date_text()+'</div><div class="most_recent_audition_content">'+mostRecentAudition.notes+'</div>'
      else:
        # No auditions
        return 'No auditions'
    most_recent_audition_tag.allow_tags = True
示例#23
0
class EmergencyContact(models.Model):
    fname = models.CharField(max_length=255, verbose_name="First Name")
    mname = models.CharField(max_length=255, blank=True, null=True, verbose_name="Middle Name")
    lname = models.CharField(max_length=255, verbose_name="Last Name")
    relationship_to_student = models.CharField(max_length=500, blank=True)
    street = models.CharField(max_length=255, blank=True, null=True, help_text="Include apt number")
    city = models.CharField(max_length=255, blank=True, null=True, default=get_city)
    state = USStateField(blank=True, null=True)
    zip = models.CharField(max_length=10, blank=True, null=True)
    email = models.EmailField(blank=True, null=True)
    primary_contact = models.BooleanField(default=True, help_text="This contact is where mailings should be sent to. In the event of an emergency, this is the person that will be contacted first.")
    emergency_only = models.BooleanField(help_text="Only contact in case of emergency")
    sync_schoolreach = models.BooleanField(help_text="Sync this contact with schoolreach",default=True)
    
    class Meta:
        ordering = ('primary_contact', 'lname') 
        verbose_name = "Student Contact"
    
    def __unicode__(self):
        txt = self.fname + " " + self.lname
        for number in self.emergencycontactnumber_set.all():
            txt += " " + unicode(number)
        return txt
    
    def save(self, *args, **kwargs):
        super(EmergencyContact, self).save(*args, **kwargs)
        self.cache_student_addresses()
    
    def cache_student_addresses(self):
        """cache these for the student for primary contact only
        There is another check on Student in case all contacts where deleted"""
        if self.primary_contact:
            for student in self.student_set.all():
                student.parent_guardian = self.fname + " " + self.lname
                student.city = self.city
                student.street = self.street
                student.state = self.state
                student.zip = self.zip
                student.parent_email = self.email
                student.save()
                for contact in student.emergency_contacts.exclude(id=self.id):
                    # There should only be one primary contact!
                    if contact.primary_contact:
                        contact.primary_contact = False
                        contact.save()
            # cache these for the applicant
            if hasattr(self, 'applicant_set'):
                for applicant in self.applicant_set.all():
                    applicant.set_cache(self)
    
    def show_student(self):
        students = ""
        for student in self.student_set.all():
            students += "{}, ".format(student)
        return students[:-2]
示例#24
0
class Intersection(models.Model):
    """
    A point representing the meeting of two Streets
    (refers to them only by name).
    """
    pretty_name = models.CharField(max_length=255, unique=True) # eg., "N. Kimball Ave. & W. Diversey Ave.
    slug = models.SlugField(max_length=64) # eg., "n-kimball-ave-and-w-diversey-ave"
    # Street A
    predir_a = models.CharField(max_length=2, blank=True, db_index=True) # eg., "N"
    prefix_a = models.CharField(max_length=32, blank=True, db_index=True) # eg., "US HWY"
    street_a = models.CharField(max_length=255, db_index=True) # eg., "KIMBALL"
    suffix_a = models.CharField(max_length=32, blank=True, db_index=True) # eg., "AVE"
    postdir_a = models.CharField(max_length=2, blank=True, db_index=True) # eg., "NW"
    # Street B
    predir_b = models.CharField(max_length=2, blank=True, db_index=True) # eg., "W"
    prefix_b = models.CharField(max_length=32, blank=True, db_index=True) # eg., "US HWY"
    street_b = models.CharField(max_length=255, db_index=True) # eg., "DIVERSEY"
    suffix_b = models.CharField(max_length=32, blank=True, db_index=True) # eg., "AVE"
    postdir_b = models.CharField(max_length=2, blank=True, db_index=True) # eg., "SE"
    zip = models.CharField(max_length=10, db_index=True) # Possible Plus-4
    city = models.CharField(max_length=255, db_index=True) # Always uppercase
    state = USStateField(db_index=True) # Always uppercase. TODO: bad for i18n!
    location = models.PointField()
    objects = IntersectionManager()

    class Meta:
        db_table = 'intersections'
        # TODO: This unique_together is just a silly assumption.
        # There are places where the same two streets cross multiple
        # times even within one area (city, zip code, whatever).
        # Example off the top of my head -
        # http://g.co/maps/pcxsm
        # - route 28 and old route 28 intersect what, 4 times in the space of
        # a mile or two?
        unique_together = ("predir_a", "prefix_a", "street_a", "suffix_a", "postdir_a",
                           "predir_b", "prefix_b", "street_b", "suffix_b", "postdir_b")
        ordering = ('slug',)

    def __unicode__(self):
        return self.pretty_name

    def reverse_pretty_name(self):
        return u" & ".join(self.pretty_name.split(" & ")[::-1])

    def url(self):
        # Use the URL of the first block found of those which comprise
        # this intersection.
        try:
            first_block = self.blockintersection_set.all()[0].block
        except IndexError:
            return ''
        return first_block.url()

    def alert_url(self):
        return '%salerts/' % self.url()
class StickerRecipient(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    email = models.EmailField()
    address = models.CharField(max_length=100)
    city = models.CharField(max_length=50)
    state = USStateField()
    zipcode = models.CharField(max_length=10)
    user = models.ForeignKey("auth.user", blank=True, null=True, db_index=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
示例#26
0
文件: models.py 项目: jedmund/Focus
class Venue(models.Model):
    name     = models.CharField(max_length=400)
    address  = models.CharField(max_length=400)
    city     = models.CharField(max_length=255)
    state    = USStateField()
    zip_code = models.CharField(max_length=5)
    cross_st = models.CharField(max_length=255, blank=True, null=True)
    phone    = PhoneNumberField()

    def __unicode__(self):
        return self.name
示例#27
0
class Bowl(models.Model):
    name = models.CharField(max_length=100, unique=True)
    city = models.CharField(max_length=100)
    state = USStateField()
    slug = models.CharField(max_length=50, unique=True)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ('name',)
示例#28
0
class Intersection(models.Model):
    pretty_name = models.CharField(
        max_length=255,
        unique=True)  # eg., "N. Kimball Ave. & W. Diversey Ave.
    slug = models.SlugField(
        max_length=64)  # eg., "n-kimball-ave-and-w-diversey-ave"
    # Street A
    predir_a = models.CharField(max_length=2, blank=True,
                                db_index=True)  # eg., "N"
    street_a = models.CharField(max_length=255,
                                db_index=True)  # eg., "KIMBALL"
    suffix_a = models.CharField(max_length=32, blank=True,
                                db_index=True)  # eg., "AVE"
    postdir_a = models.CharField(max_length=2, blank=True,
                                 db_index=True)  # eg., "NW"
    # Street B
    predir_b = models.CharField(max_length=2, blank=True,
                                db_index=True)  # eg., "W"
    street_b = models.CharField(max_length=255,
                                db_index=True)  # eg., "DIVERSEY"
    suffix_b = models.CharField(max_length=32, blank=True,
                                db_index=True)  # eg., "AVE"
    postdir_b = models.CharField(max_length=2, blank=True,
                                 db_index=True)  # eg., "SE"
    zip = models.CharField(max_length=10, db_index=True)  # Possible Plus-4
    city = models.CharField(max_length=255, db_index=True)  # Always uppercase
    state = USStateField(db_index=True)  # Always uppercase
    location = models.PointField()
    objects = IntersectionManager()

    class Meta:
        db_table = 'intersections'
        unique_together = ("predir_a", "street_a", "suffix_a", "postdir_a",
                           "predir_b", "street_b", "suffix_b", "postdir_b")

    def __unicode__(self):
        return self.pretty_name

    def reverse_pretty_name(self):
        return u" & ".join(self.pretty_name.split(" & ")[::-1])

    def url(self):
        # Use the URL of the first block found of those which comprise
        # this intersection.
        try:
            first_block = self.blockintersection_set.all()[0].block
        except IndexError:
            return ''
        return first_block.url()

    def alert_url(self):
        return '%salerts/' % self.url()
示例#29
0
文件: models.py 项目: HNK7/helio
class Address(models.Model):
    street_line1 = models.CharField(max_length=100, blank=True, null=True)
    street_line2 = models.CharField(max_length=100, blank=True, null=True)
    zipcode = models.CharField(max_length=5, blank=True, null=True)
    city = models.CharField(max_length=100, blank=True, null=True)
    # state = models.CharField(max_length=100, null=True)
    state = USStateField(blank=True, null=True)
    country = models.CharField(max_length=100,
                               blank=True,
                               null=True,
                               default='US')

    class Meta:
        abstract = True
示例#30
0
class User(models.Model):
    username = models.CharField(max_length=40)
    group = models.ForeignKey(Group)
    birthday = models.DateField(help_text="Teh Birthday")
    email = models.EmailField(blank=True)
    posts = models.PositiveSmallIntegerField()
    state = USStateField()
    reg_ip = models.IPAddressField("IP Addy")
    url = models.URLField()
    file = models.FilePathField()
    file2 = models.FileField(upload_to='.')
    bool = models.BooleanField()
    time1 = models.TimeField()
    slug = models.SlugField()