annotate mysite/band/models.py @ 1:0dcfcdf50c62

Initial import of Madeira project from the private repository.
author Brian Neal <bgneal@gmail.com>
date Mon, 06 Apr 2009 03:10:59 +0000
parents
children e602b5302b94
rev   line source
bgneal@1 1 from django.db import models
bgneal@1 2 from django.contrib.localflavor.us.models import USStateField
bgneal@1 3 from django.contrib.localflavor.us.models import PhoneNumberField
bgneal@1 4
bgneal@1 5 from mysite.photologue.models import Photo
bgneal@1 6 import datetime
bgneal@1 7 import random
bgneal@1 8 import string
bgneal@1 9
bgneal@1 10 #######################################################################
bgneal@1 11
bgneal@1 12 class SiteConfig(models.Model):
bgneal@1 13 band_name = models.CharField(max_length = 50)
bgneal@1 14 url = models.URLField(verify_exists = False, max_length = 200)
bgneal@1 15 contact_email = models.EmailField()
bgneal@1 16 ordering_info = models.TextField(help_text = 'Enter instructions on how to order merchandise here')
bgneal@1 17 intro_text = models.TextField(help_text = 'This text appears on the home page.')
bgneal@1 18 intro_photo = models.ForeignKey(Photo)
bgneal@1 19
bgneal@1 20 def __unicode__(self):
bgneal@1 21 return self.band_name
bgneal@1 22
bgneal@1 23 class Meta:
bgneal@1 24 verbose_name = "Site Configuration"
bgneal@1 25 verbose_name_plural = "Site Configuration"
bgneal@1 26
bgneal@1 27 #######################################################################
bgneal@1 28
bgneal@1 29 class Member(models.Model):
bgneal@1 30 name = models.CharField(max_length = 50, db_index = True)
bgneal@1 31 nickname = models.CharField(max_length = 50, blank = True)
bgneal@1 32 instrument = models.CharField(max_length = 255)
bgneal@1 33 bio = models.TextField(blank = True)
bgneal@1 34 photo = models.FileField(upload_to = 'images/bio/', blank = True)
bgneal@1 35 order = models.SmallIntegerField(help_text = '''Controls order of display on the bio page, lower numbers displayed
bgneal@1 36 first''')
bgneal@1 37 is_active = models.BooleanField(db_index = True)
bgneal@1 38 start_date = models.DateField()
bgneal@1 39 end_date = models.DateField(blank = True, help_text = 'Only used if the member is not active',
bgneal@1 40 default = datetime.date(1985, 1, 1))
bgneal@1 41 email = models.EmailField()
bgneal@1 42
bgneal@1 43 def __unicode__(self):
bgneal@1 44 return self.name
bgneal@1 45
bgneal@1 46 class Meta:
bgneal@1 47 ordering = ('-is_active', 'name')
bgneal@1 48
bgneal@1 49 #######################################################################
bgneal@1 50
bgneal@1 51 class Gear(models.Model):
bgneal@1 52 member = models.ForeignKey(Member)
bgneal@1 53 item = models.CharField(max_length = 255)
bgneal@1 54
bgneal@1 55 def __unicode__(self):
bgneal@1 56 return self.item
bgneal@1 57
bgneal@1 58 class Meta:
bgneal@1 59 verbose_name_plural = 'Gear List'
bgneal@1 60
bgneal@1 61 #######################################################################
bgneal@1 62
bgneal@1 63 class State(models.Model):
bgneal@1 64 name = models.CharField(max_length = 16)
bgneal@1 65 abbrev = USStateField()
bgneal@1 66
bgneal@1 67 class Meta:
bgneal@1 68 ordering = ('name', )
bgneal@1 69
bgneal@1 70 def __unicode__(self):
bgneal@1 71 return self.name
bgneal@1 72
bgneal@1 73 #######################################################################
bgneal@1 74
bgneal@1 75 class City(models.Model):
bgneal@1 76 name = models.CharField(max_length = 50)
bgneal@1 77 state = models.ForeignKey(State, null = True, blank = True)
bgneal@1 78
bgneal@1 79 class Meta:
bgneal@1 80 verbose_name_plural = 'Cities'
bgneal@1 81 ordering = ('name', )
bgneal@1 82
bgneal@1 83 def __unicode__(self):
bgneal@1 84 if self.state:
bgneal@1 85 return self.name + u', ' + self.state.abbrev
bgneal@1 86 return self.name
bgneal@1 87
bgneal@1 88 #######################################################################
bgneal@1 89
bgneal@1 90 class Venue(models.Model):
bgneal@1 91 name = models.CharField(max_length = 50, db_index = True)
bgneal@1 92 url = models.URLField(verify_exists = False, blank = True)
bgneal@1 93 address = models.CharField(max_length = 255, blank = True)
bgneal@1 94 phone = PhoneNumberField(help_text = "Format: XXX-XXX-XXXX", blank = True)
bgneal@1 95 city = models.ForeignKey(City)
bgneal@1 96
bgneal@1 97 class Meta:
bgneal@1 98 ordering = ('name', )
bgneal@1 99
bgneal@1 100 def __unicode__(self):
bgneal@1 101 return self.name
bgneal@1 102
bgneal@1 103 #######################################################################
bgneal@1 104
bgneal@1 105 class Band(models.Model):
bgneal@1 106 name = models.CharField(max_length = 64)
bgneal@1 107 url = models.URLField(verify_exists = False, blank = True)
bgneal@1 108
bgneal@1 109 class Meta:
bgneal@1 110 ordering = ('name', )
bgneal@1 111
bgneal@1 112 def __unicode__(self):
bgneal@1 113 return self.name
bgneal@1 114
bgneal@1 115 #######################################################################
bgneal@1 116
bgneal@1 117 class Gig(models.Model):
bgneal@1 118 title = models.CharField(max_length = 50, blank = True, help_text = "Optional; e.g. Some Festival")
bgneal@1 119 url = models.URLField(verify_exists = False, blank = True, help_text = "Optional; e.g. Some Festival's Website")
bgneal@1 120 date = models.DateField(db_index = True)
bgneal@1 121 time = models.TimeField(null = True, blank = True)
bgneal@1 122 venue = models.ForeignKey(Venue, null = True, blank = True)
bgneal@1 123 notes = models.TextField(blank = True)
bgneal@1 124 bands = models.ManyToManyField(Band, blank = True)
bgneal@1 125 flyer = models.ForeignKey(Photo, null = True, blank = True)
bgneal@1 126
bgneal@1 127 def __unicode__(self):
bgneal@1 128 if self.title:
bgneal@1 129 return u'%s %s %s' % (self.date.strftime('%m/%d/%Y'), self.title, self.venue.name)
bgneal@1 130 elif self.venue:
bgneal@1 131 return u'%s %s' % (self.date.strftime('%m/%d/%Y'), self.venue.name)
bgneal@1 132 else:
bgneal@1 133 return u'' + self.date.strftime('%m/%d/%Y')
bgneal@1 134
bgneal@1 135 class Meta:
bgneal@1 136 ordering = ('-date', 'time')
bgneal@1 137
bgneal@1 138 #######################################################################
bgneal@1 139
bgneal@1 140 class News(models.Model):
bgneal@1 141 title = models.CharField(max_length = 64, blank = True)
bgneal@1 142 date = models.DateField(db_index = True)
bgneal@1 143 author = models.CharField(max_length = 50, blank = True)
bgneal@1 144 text = models.TextField()
bgneal@1 145 markup_enabled = models.BooleanField(default = True,
bgneal@1 146 help_text = 'Check this box to allow Textile style markup in the text field')
bgneal@1 147 photo = models.FileField(upload_to = 'images/news/%Y/%m/%d/', blank = True)
bgneal@1 148 photo_caption = models.CharField(max_length = 50, blank = True)
bgneal@1 149
bgneal@1 150 def __unicode__(self):
bgneal@1 151 return u'%s %s' % (self.date.strftime('%m/%d/%Y'), self.title)
bgneal@1 152
bgneal@1 153 class Meta:
bgneal@1 154 ordering = ('-date', )
bgneal@1 155 verbose_name_plural = "News"
bgneal@1 156
bgneal@1 157 #######################################################################
bgneal@1 158
bgneal@1 159 class Article(models.Model):
bgneal@1 160 title = models.CharField(max_length = 64)
bgneal@1 161 date = models.DateField(db_index = True)
bgneal@1 162 text = models.TextField()
bgneal@1 163 markup_enabled = models.BooleanField(default = True,
bgneal@1 164 help_text = 'Check this box to allow Textile style markup in the text field')
bgneal@1 165 source = models.TextField(help_text = '''Enter the source/author for the article, copyright info, etc; it will appear under
bgneal@1 166 the article.''')
bgneal@1 167 url = models.URLField(blank = True, help_text = 'Link to original article; optional')
bgneal@1 168 pdf = models.FileField(upload_to = 'pdf/articles/%Y/%m/%d/', blank = True,
bgneal@1 169 help_text = '''If you want to make the original article available as a PDF download, you may upload it
bgneal@1 170 here.''')
bgneal@1 171
bgneal@1 172 def __unicode__(self):
bgneal@1 173 return self.title
bgneal@1 174
bgneal@1 175 class Meta:
bgneal@1 176 ordering = ('date', )
bgneal@1 177
bgneal@1 178 #######################################################################
bgneal@1 179
bgneal@1 180 class Mp3_Set(models.Model):
bgneal@1 181 date = models.DateField(auto_now_add = True, editable = False)
bgneal@1 182 title = models.CharField(max_length = 64)
bgneal@1 183 text = models.TextField()
bgneal@1 184
bgneal@1 185 def __unicode__(self):
bgneal@1 186 return self.title
bgneal@1 187
bgneal@1 188 class Meta:
bgneal@1 189 ordering = ('date', )
bgneal@1 190 verbose_name = "MP3 Set"
bgneal@1 191
bgneal@1 192 #######################################################################
bgneal@1 193
bgneal@1 194 class Mp3(models.Model):
bgneal@1 195 mp3_set = models.ForeignKey(Mp3_Set)
bgneal@1 196 title = models.CharField(max_length = 64)
bgneal@1 197 desc = models.CharField(max_length = 128, blank = True)
bgneal@1 198 file = models.FileField(upload_to = 'mp3s/%Y/%m/%d/')
bgneal@1 199 slug = models.SlugField(unique = True)
bgneal@1 200
bgneal@1 201 def __unicode__(self):
bgneal@1 202 return self.title
bgneal@1 203
bgneal@1 204 class Meta:
bgneal@1 205 ordering = ('title', )
bgneal@1 206 verbose_name = "MP3"
bgneal@1 207
bgneal@1 208 #######################################################################
bgneal@1 209
bgneal@1 210 class Video_Set(models.Model):
bgneal@1 211 date = models.DateField(auto_now_add = True, editable = False)
bgneal@1 212 title = models.CharField(max_length = 64)
bgneal@1 213 text = models.TextField()
bgneal@1 214
bgneal@1 215 def __unicode__(self):
bgneal@1 216 return self.title
bgneal@1 217
bgneal@1 218 class Meta:
bgneal@1 219 ordering = ('date', )
bgneal@1 220 verbose_name = "Video Set"
bgneal@1 221
bgneal@1 222 #######################################################################
bgneal@1 223
bgneal@1 224 class Video(models.Model):
bgneal@1 225 video_set = models.ForeignKey(Video_Set)
bgneal@1 226 title = models.CharField(max_length = 64)
bgneal@1 227 embed_code = models.CharField(max_length = 1024)
bgneal@1 228
bgneal@1 229 def __unicode__(self):
bgneal@1 230 return self.title
bgneal@1 231
bgneal@1 232 class Meta:
bgneal@1 233 ordering = ('title', )
bgneal@1 234
bgneal@1 235 #######################################################################
bgneal@1 236
bgneal@1 237 class Record_Label(models.Model):
bgneal@1 238 name = models.CharField(max_length = 64)
bgneal@1 239 url = models.URLField(verify_exists = False, max_length = 200)
bgneal@1 240
bgneal@1 241 def __unicode__(self):
bgneal@1 242 return self.name
bgneal@1 243
bgneal@1 244 class Meta:
bgneal@1 245 verbose_name = 'Record Label'
bgneal@1 246
bgneal@1 247 #######################################################################
bgneal@1 248
bgneal@1 249 class Album(models.Model):
bgneal@1 250 title = models.CharField(max_length = 64)
bgneal@1 251 photo = models.ForeignKey(Photo)
bgneal@1 252 desc = models.TextField(blank = True)
bgneal@1 253
bgneal@1 254 def __unicode__(self):
bgneal@1 255 return self.title
bgneal@1 256
bgneal@1 257 class Meta:
bgneal@1 258 pass
bgneal@1 259
bgneal@1 260 #######################################################################
bgneal@1 261
bgneal@1 262 class Album_Track(models.Model):
bgneal@1 263 album = models.ForeignKey(Album)
bgneal@1 264 track_number = models.SmallIntegerField()
bgneal@1 265 track_name = models.CharField(max_length = 64)
bgneal@1 266
bgneal@1 267 def __unicode__(self):
bgneal@1 268 return self.track_name
bgneal@1 269
bgneal@1 270 class Meta:
bgneal@1 271 verbose_name = 'Album Track'
bgneal@1 272 ordering = ('album', 'track_number', )
bgneal@1 273
bgneal@1 274 #######################################################################
bgneal@1 275
bgneal@1 276 class Label_Release(models.Model):
bgneal@1 277 record_label = models.ForeignKey(Record_Label)
bgneal@1 278 album = models.ForeignKey(Album)
bgneal@1 279 catalog_number = models.CharField(max_length = 32)
bgneal@1 280 release_date = models.DateField()
bgneal@1 281
bgneal@1 282 def __unicode__(self):
bgneal@1 283 return u'%s %s %s' % (self.record_label.name, self.album.title, self.catalog_number)
bgneal@1 284
bgneal@1 285 class Meta:
bgneal@1 286 verbose_name = 'Label Release'
bgneal@1 287
bgneal@1 288 #######################################################################
bgneal@1 289
bgneal@1 290 class Album_Merchant(models.Model):
bgneal@1 291 album = models.ForeignKey(Album)
bgneal@1 292 name = models.CharField(max_length = 64)
bgneal@1 293 url = models.URLField(verify_exists = False, max_length = 200)
bgneal@1 294
bgneal@1 295 def __unicode__(self):
bgneal@1 296 return u'%s (%s)' % (self.name, self.album.title)
bgneal@1 297
bgneal@1 298 class Meta:
bgneal@1 299 verbose_name = 'Album Merchant'
bgneal@1 300 ordering = ('name', )
bgneal@1 301
bgneal@1 302 #######################################################################
bgneal@1 303
bgneal@1 304 class Merchandise(models.Model):
bgneal@1 305 name = models.CharField(max_length = 64)
bgneal@1 306 desc = models.TextField()
bgneal@1 307 price = models.DecimalField(max_digits = 5, decimal_places = 2)
bgneal@1 308 in_stock = models.BooleanField()
bgneal@1 309 photo = models.ForeignKey(Photo)
bgneal@1 310
bgneal@1 311 def __unicode__(self):
bgneal@1 312 return self.name
bgneal@1 313
bgneal@1 314 class Meta:
bgneal@1 315 verbose_name_plural = "Merchandise"
bgneal@1 316
bgneal@1 317 #######################################################################
bgneal@1 318
bgneal@1 319 class Fan(models.Model):
bgneal@1 320 statusCodes = (('P', 'Pending'), ('A', 'Active'), ('L', 'Leaving'))
bgneal@1 321 keyLength = 16
bgneal@1 322
bgneal@1 323 name = models.CharField(max_length = 32, blank = True)
bgneal@1 324 email = models.EmailField(db_index = True)
bgneal@1 325 location = models.CharField(max_length = 64, blank = True)
bgneal@1 326 status = models.CharField(max_length = 1, choices = statusCodes, default = 'A',
bgneal@1 327 editable = False, db_index = True)
bgneal@1 328 key = models.CharField(max_length = keyLength, editable = False, blank = True, db_index = True)
bgneal@1 329 status_date = models.DateField(default = datetime.date.today, editable = False, db_index = True)
bgneal@1 330
bgneal@1 331 def __unicode__(self):
bgneal@1 332 if self.name:
bgneal@1 333 return u'%s <%s>' % (self.name, self.email)
bgneal@1 334 return self.email
bgneal@1 335
bgneal@1 336 class Meta:
bgneal@1 337 ordering = ('name', 'email')
bgneal@1 338
bgneal@1 339 def setPending(self):
bgneal@1 340 self.status = 'P'
bgneal@1 341 self.status_date = datetime.date.today()
bgneal@1 342 self.genKey()
bgneal@1 343
bgneal@1 344 def setActive(self):
bgneal@1 345 self.status = 'A'
bgneal@1 346 self.status_date = datetime.date.today()
bgneal@1 347
bgneal@1 348 def setLeaving(self):
bgneal@1 349 self.status = 'L'
bgneal@1 350 self.status_date = datetime.date.today()
bgneal@1 351 self.genKey()
bgneal@1 352
bgneal@1 353 def isPending(self):
bgneal@1 354 return self.status == 'P'
bgneal@1 355
bgneal@1 356 def isLeaving(self):
bgneal@1 357 return self.status == 'L'
bgneal@1 358
bgneal@1 359 def isActive(self):
bgneal@1 360 return self.status == 'A'
bgneal@1 361
bgneal@1 362 def current_status(self):
bgneal@1 363 if self.status == 'P':
bgneal@1 364 return 'Pending'
bgneal@1 365 elif self.status == 'L':
bgneal@1 366 return 'Leaving'
bgneal@1 367 elif self.status == 'A':
bgneal@1 368 return 'Active'
bgneal@1 369 else:
bgneal@1 370 return 'Unknown'
bgneal@1 371
bgneal@1 372 def genKey(self):
bgneal@1 373 self.key = ''.join(random.sample(string.ascii_letters + string.digits, self.keyLength))
bgneal@1 374