diff band/models.py @ 71:e2868ad47a1e

For Django 1.4, using the new manage.py.
author Brian Neal <bgneal@gmail.com>
date Sat, 14 Apr 2012 16:40:29 -0500
parents madeira/band/models.py@e17fc6bbb9b0
children 27b38cc65ca4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/band/models.py	Sat Apr 14 16:40:29 2012 -0500
@@ -0,0 +1,111 @@
+"""
+Models for the band application.
+
+"""
+from django.db import models
+
+from photologue.models import Photo
+
+
+class Member(models.Model):
+    name = models.CharField(max_length=50)
+    nickname = models.CharField(max_length=50, blank=True)
+    instrument = models.CharField(max_length=255)
+    bio = models.TextField(blank=True)
+    photo = models.ImageField(upload_to='images/bio/', blank=True)
+    order = models.SmallIntegerField(
+        help_text = "Controls order of display; lower numbers displayed first")
+    is_active = models.BooleanField()
+    start_date = models.DateField()
+    end_date = models.DateField(blank=True,
+        null=True,
+        help_text="Only used if the member is not active")
+    email = models.EmailField()
+
+    def __unicode__(self):
+        return self.name
+
+    class Meta:
+        ordering = ['-is_active', 'name']
+
+
+class Gear(models.Model):
+    member = models.ForeignKey(Member)
+    item = models.CharField(max_length=255)
+
+    def __unicode__(self):
+        return self.item
+
+    class Meta:
+        verbose_name_plural = 'Gear List'
+
+
+class RecordLabel(models.Model):
+    name = models.CharField(max_length=64)
+    url = models.URLField(max_length=200)
+
+    def __unicode__(self):
+        return self.name
+
+
+class Album(models.Model):
+    title = models.CharField(max_length=64)
+    photo = models.ForeignKey(Photo)
+    desc = models.TextField(blank=True)
+
+    def __unicode__(self):
+        return self.title
+
+
+class AlbumTrack(models.Model):
+    album = models.ForeignKey(Album, related_name='tracks')
+    track_number = models.SmallIntegerField()
+    track_name = models.CharField(max_length=64)
+
+    def __unicode__(self):
+        return self.track_name
+
+    class Meta:
+        verbose_name = 'Album Track'
+        ordering = ['album', 'track_number']
+
+
+class LabelRelease(models.Model):
+    record_label = models.ForeignKey(RecordLabel)
+    album = models.ForeignKey(Album, related_name='labels')
+    catalog_number = models.CharField(max_length=32)
+    release_date = models.DateField()
+
+    def __unicode__(self):
+        return u'%s %s %s' % (self.record_label.name, self.album.title,
+                self.catalog_number)
+
+    class Meta:
+        verbose_name = 'Label Release'
+
+
+class AlbumMerchant(models.Model):
+    album = models.ForeignKey(Album, related_name='merchants')
+    name = models.CharField(max_length=64)
+    url = models.URLField(max_length=200)
+
+    def __unicode__(self):
+        return u'%s (%s)' % (self.name, self.album.title)
+
+    class Meta:
+        verbose_name = 'Album Merchant'
+        ordering = ['name']
+
+
+class Merchandise(models.Model):
+    name = models.CharField(max_length=64)
+    desc = models.TextField()
+    price = models.DecimalField(max_digits=5, decimal_places=2)
+    in_stock = models.BooleanField()
+    photo = models.ForeignKey(Photo)
+
+    def __unicode__(self):
+        return self.name
+
+    class Meta:
+        verbose_name_plural = "Merchandise"