Mercurial > public > madeira
view gigs/models.py @ 74:49f704e58400
Update fabfile for Django 1.4 changes.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Jul 2012 13:55:25 -0500 |
parents | e2868ad47a1e |
children | 447d75d1e21d |
line wrap: on
line source
""" Models for the gigs application. """ from django.db import models from django.contrib.localflavor.us.models import USStateField from django.contrib.localflavor.us.models import PhoneNumberField from photologue.models import Photo class Country(models.Model): name = models.CharField(max_length=64) class Meta: ordering = ['name'] verbose_name_plural = 'Countries' def __unicode__(self): return self.name class State(models.Model): name = models.CharField(max_length=16) abbrev = USStateField() class Meta: ordering = ['name'] def __unicode__(self): return self.name class City(models.Model): name = models.CharField(max_length=50) state = models.ForeignKey(State, null=True, blank=True) country = models.ForeignKey(Country, null=True, blank=True) class Meta: verbose_name_plural = 'Cities' ordering = ['name'] def __unicode__(self): if self.state: return u'%s, %s' % (self.name, self.state.abbrev) return self.name class Venue(models.Model): name = models.CharField(max_length=50) url = models.URLField(blank=True) address = models.CharField(max_length=255, blank=True) phone = PhoneNumberField(help_text="Format: XXX-XXX-XXXX", blank=True) city = models.ForeignKey(City) class Meta: ordering = ['name'] def __unicode__(self): return self.name class Band(models.Model): name = models.CharField(max_length=64) url = models.URLField(blank=True) class Meta: ordering = ['name'] def __unicode__(self): return self.name class Gig(models.Model): title = models.CharField(max_length=50, blank=True, help_text="Optional; e.g. Some Festival") url = models.URLField(blank=True, help_text="Optional; e.g. Some Festival's Website") date = models.DateField(db_index=True) time = models.TimeField(null=True, blank=True) venue = models.ForeignKey(Venue, null=True, blank=True) notes = models.TextField(blank=True) bands = models.ManyToManyField(Band, blank=True) flyer = models.ForeignKey(Photo, null=True, blank=True, related_name='gig_flyers') def __unicode__(self): if self.title: return u'%s %s %s' % (self.date.strftime('%m/%d/%Y'), self.title, self.venue.name) elif self.venue: return u'%s %s' % (self.date.strftime('%m/%d/%Y'), self.venue.name) else: return self.date.strftime('%m/%d/%Y') class Meta: ordering = ['-date', 'time']