annotate band/models.py @ 111:23efa49f5e29

Bootstrap: flyers page.
author Brian Neal <bgneal@gmail.com>
date Sat, 19 Oct 2013 17:18:25 -0500
parents e2868ad47a1e
children 27b38cc65ca4
rev   line source
bgneal@55 1 """
bgneal@55 2 Models for the band application.
bgneal@55 3
bgneal@55 4 """
bgneal@1 5 from django.db import models
bgneal@1 6
bgneal@40 7 from photologue.models import Photo
bgneal@1 8
bgneal@1 9
bgneal@1 10 class Member(models.Model):
bgneal@55 11 name = models.CharField(max_length=50)
bgneal@55 12 nickname = models.CharField(max_length=50, blank=True)
bgneal@55 13 instrument = models.CharField(max_length=255)
bgneal@55 14 bio = models.TextField(blank=True)
bgneal@55 15 photo = models.ImageField(upload_to='images/bio/', blank=True)
bgneal@55 16 order = models.SmallIntegerField(
bgneal@55 17 help_text = "Controls order of display; lower numbers displayed first")
bgneal@55 18 is_active = models.BooleanField()
bgneal@55 19 start_date = models.DateField()
bgneal@55 20 end_date = models.DateField(blank=True,
bgneal@55 21 null=True,
bgneal@55 22 help_text="Only used if the member is not active")
bgneal@55 23 email = models.EmailField()
bgneal@5 24
bgneal@5 25 def __unicode__(self):
bgneal@5 26 return self.name
bgneal@5 27
bgneal@55 28 class Meta:
bgneal@55 29 ordering = ['-is_active', 'name']
bgneal@5 30
bgneal@1 31
bgneal@55 32 class Gear(models.Model):
bgneal@55 33 member = models.ForeignKey(Member)
bgneal@55 34 item = models.CharField(max_length=255)
bgneal@1 35
bgneal@55 36 def __unicode__(self):
bgneal@55 37 return self.item
bgneal@1 38
bgneal@55 39 class Meta:
bgneal@55 40 verbose_name_plural = 'Gear List'
bgneal@1 41
bgneal@1 42
bgneal@55 43 class RecordLabel(models.Model):
bgneal@55 44 name = models.CharField(max_length=64)
bgneal@64 45 url = models.URLField(max_length=200)
bgneal@1 46
bgneal@55 47 def __unicode__(self):
bgneal@55 48 return self.name
bgneal@1 49
bgneal@1 50
bgneal@1 51 class Album(models.Model):
bgneal@55 52 title = models.CharField(max_length=64)
bgneal@55 53 photo = models.ForeignKey(Photo)
bgneal@55 54 desc = models.TextField(blank=True)
bgneal@1 55
bgneal@55 56 def __unicode__(self):
bgneal@55 57 return self.title
bgneal@1 58
bgneal@1 59
bgneal@55 60 class AlbumTrack(models.Model):
bgneal@57 61 album = models.ForeignKey(Album, related_name='tracks')
bgneal@55 62 track_number = models.SmallIntegerField()
bgneal@55 63 track_name = models.CharField(max_length=64)
bgneal@1 64
bgneal@55 65 def __unicode__(self):
bgneal@55 66 return self.track_name
bgneal@1 67
bgneal@55 68 class Meta:
bgneal@55 69 verbose_name = 'Album Track'
bgneal@55 70 ordering = ['album', 'track_number']
bgneal@1 71
bgneal@1 72
bgneal@55 73 class LabelRelease(models.Model):
bgneal@55 74 record_label = models.ForeignKey(RecordLabel)
bgneal@57 75 album = models.ForeignKey(Album, related_name='labels')
bgneal@55 76 catalog_number = models.CharField(max_length=32)
bgneal@55 77 release_date = models.DateField()
bgneal@1 78
bgneal@55 79 def __unicode__(self):
bgneal@55 80 return u'%s %s %s' % (self.record_label.name, self.album.title,
bgneal@55 81 self.catalog_number)
bgneal@1 82
bgneal@55 83 class Meta:
bgneal@55 84 verbose_name = 'Label Release'
bgneal@1 85
bgneal@1 86
bgneal@55 87 class AlbumMerchant(models.Model):
bgneal@57 88 album = models.ForeignKey(Album, related_name='merchants')
bgneal@55 89 name = models.CharField(max_length=64)
bgneal@64 90 url = models.URLField(max_length=200)
bgneal@1 91
bgneal@55 92 def __unicode__(self):
bgneal@55 93 return u'%s (%s)' % (self.name, self.album.title)
bgneal@1 94
bgneal@55 95 class Meta:
bgneal@55 96 verbose_name = 'Album Merchant'
bgneal@55 97 ordering = ['name']
bgneal@1 98
bgneal@1 99
bgneal@1 100 class Merchandise(models.Model):
bgneal@55 101 name = models.CharField(max_length=64)
bgneal@55 102 desc = models.TextField()
bgneal@55 103 price = models.DecimalField(max_digits=5, decimal_places=2)
bgneal@55 104 in_stock = models.BooleanField()
bgneal@55 105 photo = models.ForeignKey(Photo)
bgneal@1 106
bgneal@55 107 def __unicode__(self):
bgneal@55 108 return self.name
bgneal@1 109
bgneal@55 110 class Meta:
bgneal@55 111 verbose_name_plural = "Merchandise"