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