view band/models.py @ 139:c962f58c2693

Support photologue photo detail views to prevent 404s in the admin.
author Brian Neal <bgneal@gmail.com>
date Sat, 08 Mar 2014 13:19:10 -0600
parents e2868ad47a1e
children 27b38cc65ca4
line wrap: on
line source
"""
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"