annotate mysite/band/models.py @ 33:7d8015de651a

Removed old reference to /media in the admin/base_site.html template for the favicon.
author Brian Neal <bgneal@gmail.com>
date Wed, 02 Nov 2011 01:30:46 +0000
parents dac690ab98b2
children 25e00d1b99bf
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@5 63 class Country(models.Model):
bgneal@5 64 name = models.CharField(max_length=64)
bgneal@5 65
bgneal@5 66 class Meta:
bgneal@5 67 ordering = ('name', )
bgneal@5 68 verbose_name_plural = 'Countries'
bgneal@5 69
bgneal@5 70 def __unicode__(self):
bgneal@5 71 return self.name
bgneal@5 72
bgneal@5 73 #######################################################################
bgneal@5 74
bgneal@1 75 class State(models.Model):
bgneal@1 76 name = models.CharField(max_length = 16)
bgneal@1 77 abbrev = USStateField()
bgneal@1 78
bgneal@1 79 class Meta:
bgneal@1 80 ordering = ('name', )
bgneal@1 81
bgneal@1 82 def __unicode__(self):
bgneal@1 83 return self.name
bgneal@1 84
bgneal@1 85 #######################################################################
bgneal@1 86
bgneal@1 87 class City(models.Model):
bgneal@1 88 name = models.CharField(max_length = 50)
bgneal@1 89 state = models.ForeignKey(State, null = True, blank = True)
bgneal@5 90 country = models.ForeignKey(Country, null=True, blank=True)
bgneal@1 91
bgneal@1 92 class Meta:
bgneal@1 93 verbose_name_plural = 'Cities'
bgneal@1 94 ordering = ('name', )
bgneal@1 95
bgneal@1 96 def __unicode__(self):
bgneal@1 97 if self.state:
bgneal@1 98 return self.name + u', ' + self.state.abbrev
bgneal@1 99 return self.name
bgneal@1 100
bgneal@1 101 #######################################################################
bgneal@1 102
bgneal@1 103 class Venue(models.Model):
bgneal@1 104 name = models.CharField(max_length = 50, db_index = True)
bgneal@1 105 url = models.URLField(verify_exists = False, blank = True)
bgneal@1 106 address = models.CharField(max_length = 255, blank = True)
bgneal@1 107 phone = PhoneNumberField(help_text = "Format: XXX-XXX-XXXX", blank = True)
bgneal@1 108 city = models.ForeignKey(City)
bgneal@1 109
bgneal@1 110 class Meta:
bgneal@1 111 ordering = ('name', )
bgneal@1 112
bgneal@1 113 def __unicode__(self):
bgneal@1 114 return self.name
bgneal@1 115
bgneal@1 116 #######################################################################
bgneal@1 117
bgneal@1 118 class Band(models.Model):
bgneal@1 119 name = models.CharField(max_length = 64)
bgneal@1 120 url = models.URLField(verify_exists = False, blank = True)
bgneal@1 121
bgneal@1 122 class Meta:
bgneal@1 123 ordering = ('name', )
bgneal@1 124
bgneal@1 125 def __unicode__(self):
bgneal@1 126 return self.name
bgneal@1 127
bgneal@1 128 #######################################################################
bgneal@1 129
bgneal@1 130 class Gig(models.Model):
bgneal@1 131 title = models.CharField(max_length = 50, blank = True, help_text = "Optional; e.g. Some Festival")
bgneal@1 132 url = models.URLField(verify_exists = False, blank = True, help_text = "Optional; e.g. Some Festival's Website")
bgneal@1 133 date = models.DateField(db_index = True)
bgneal@1 134 time = models.TimeField(null = True, blank = True)
bgneal@1 135 venue = models.ForeignKey(Venue, null = True, blank = True)
bgneal@1 136 notes = models.TextField(blank = True)
bgneal@1 137 bands = models.ManyToManyField(Band, blank = True)
bgneal@1 138 flyer = models.ForeignKey(Photo, null = True, blank = True)
bgneal@1 139
bgneal@1 140 def __unicode__(self):
bgneal@1 141 if self.title:
bgneal@1 142 return u'%s %s %s' % (self.date.strftime('%m/%d/%Y'), self.title, self.venue.name)
bgneal@1 143 elif self.venue:
bgneal@1 144 return u'%s %s' % (self.date.strftime('%m/%d/%Y'), self.venue.name)
bgneal@1 145 else:
bgneal@1 146 return u'' + self.date.strftime('%m/%d/%Y')
bgneal@1 147
bgneal@1 148 class Meta:
bgneal@1 149 ordering = ('-date', 'time')
bgneal@1 150
bgneal@1 151 #######################################################################
bgneal@1 152
bgneal@1 153 class News(models.Model):
bgneal@1 154 title = models.CharField(max_length = 64, blank = True)
bgneal@1 155 date = models.DateField(db_index = True)
bgneal@1 156 author = models.CharField(max_length = 50, blank = True)
bgneal@1 157 text = models.TextField()
bgneal@1 158 markup_enabled = models.BooleanField(default = True,
bgneal@1 159 help_text = 'Check this box to allow Textile style markup in the text field')
bgneal@1 160 photo = models.FileField(upload_to = 'images/news/%Y/%m/%d/', blank = True)
bgneal@1 161 photo_caption = models.CharField(max_length = 50, blank = True)
bgneal@1 162
bgneal@1 163 def __unicode__(self):
bgneal@1 164 return u'%s %s' % (self.date.strftime('%m/%d/%Y'), self.title)
bgneal@1 165
bgneal@1 166 class Meta:
bgneal@1 167 ordering = ('-date', )
bgneal@1 168 verbose_name_plural = "News"
bgneal@1 169
bgneal@1 170 #######################################################################
bgneal@1 171
bgneal@1 172 class Article(models.Model):
bgneal@1 173 title = models.CharField(max_length = 64)
bgneal@1 174 date = models.DateField(db_index = True)
bgneal@1 175 text = models.TextField()
bgneal@1 176 markup_enabled = models.BooleanField(default = True,
bgneal@1 177 help_text = 'Check this box to allow Textile style markup in the text field')
bgneal@1 178 source = models.TextField(help_text = '''Enter the source/author for the article, copyright info, etc; it will appear under
bgneal@1 179 the article.''')
bgneal@1 180 url = models.URLField(blank = True, help_text = 'Link to original article; optional')
bgneal@1 181 pdf = models.FileField(upload_to = 'pdf/articles/%Y/%m/%d/', blank = True,
bgneal@1 182 help_text = '''If you want to make the original article available as a PDF download, you may upload it
bgneal@1 183 here.''')
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
bgneal@1 191 #######################################################################
bgneal@1 192
bgneal@1 193 class Mp3_Set(models.Model):
bgneal@1 194 date = models.DateField(auto_now_add = True, editable = False)
bgneal@1 195 title = models.CharField(max_length = 64)
bgneal@1 196 text = models.TextField()
bgneal@1 197
bgneal@1 198 def __unicode__(self):
bgneal@1 199 return self.title
bgneal@1 200
bgneal@1 201 class Meta:
bgneal@1 202 ordering = ('date', )
bgneal@1 203 verbose_name = "MP3 Set"
bgneal@1 204
bgneal@1 205 #######################################################################
bgneal@1 206
bgneal@1 207 class Mp3(models.Model):
bgneal@1 208 mp3_set = models.ForeignKey(Mp3_Set)
bgneal@1 209 title = models.CharField(max_length = 64)
bgneal@1 210 desc = models.CharField(max_length = 128, blank = True)
bgneal@1 211 file = models.FileField(upload_to = 'mp3s/%Y/%m/%d/')
bgneal@1 212 slug = models.SlugField(unique = True)
bgneal@1 213
bgneal@1 214 def __unicode__(self):
bgneal@1 215 return self.title
bgneal@1 216
bgneal@1 217 class Meta:
bgneal@1 218 ordering = ('title', )
bgneal@1 219 verbose_name = "MP3"
bgneal@1 220
bgneal@1 221 #######################################################################
bgneal@1 222
bgneal@1 223 class Video_Set(models.Model):
bgneal@9 224 date = models.DateField(blank=True)
bgneal@1 225 title = models.CharField(max_length = 64)
bgneal@1 226 text = models.TextField()
bgneal@1 227
bgneal@1 228 def __unicode__(self):
bgneal@1 229 return self.title
bgneal@1 230
bgneal@1 231 class Meta:
bgneal@1 232 ordering = ('date', )
bgneal@1 233 verbose_name = "Video Set"
bgneal@1 234
bgneal@9 235 def save(self, *args, **kwargs):
bgneal@9 236 if not self.id:
bgneal@9 237 self.date = datetime.date.today()
bgneal@9 238
bgneal@9 239 super(Video_Set, self).save(*args, **kwargs)
bgneal@9 240
bgneal@1 241 #######################################################################
bgneal@1 242
bgneal@1 243 class Video(models.Model):
bgneal@1 244 video_set = models.ForeignKey(Video_Set)
bgneal@1 245 title = models.CharField(max_length = 64)
bgneal@1 246 embed_code = models.CharField(max_length = 1024)
bgneal@1 247
bgneal@1 248 def __unicode__(self):
bgneal@1 249 return self.title
bgneal@1 250
bgneal@1 251 class Meta:
bgneal@1 252 ordering = ('title', )
bgneal@1 253
bgneal@1 254 #######################################################################
bgneal@1 255
bgneal@1 256 class Record_Label(models.Model):
bgneal@1 257 name = models.CharField(max_length = 64)
bgneal@1 258 url = models.URLField(verify_exists = False, max_length = 200)
bgneal@1 259
bgneal@1 260 def __unicode__(self):
bgneal@1 261 return self.name
bgneal@1 262
bgneal@1 263 class Meta:
bgneal@1 264 verbose_name = 'Record Label'
bgneal@1 265
bgneal@1 266 #######################################################################
bgneal@1 267
bgneal@1 268 class Album(models.Model):
bgneal@1 269 title = models.CharField(max_length = 64)
bgneal@1 270 photo = models.ForeignKey(Photo)
bgneal@1 271 desc = models.TextField(blank = True)
bgneal@1 272
bgneal@1 273 def __unicode__(self):
bgneal@1 274 return self.title
bgneal@1 275
bgneal@1 276 class Meta:
bgneal@1 277 pass
bgneal@1 278
bgneal@1 279 #######################################################################
bgneal@1 280
bgneal@1 281 class Album_Track(models.Model):
bgneal@1 282 album = models.ForeignKey(Album)
bgneal@1 283 track_number = models.SmallIntegerField()
bgneal@1 284 track_name = models.CharField(max_length = 64)
bgneal@1 285
bgneal@1 286 def __unicode__(self):
bgneal@1 287 return self.track_name
bgneal@1 288
bgneal@1 289 class Meta:
bgneal@1 290 verbose_name = 'Album Track'
bgneal@1 291 ordering = ('album', 'track_number', )
bgneal@1 292
bgneal@1 293 #######################################################################
bgneal@1 294
bgneal@1 295 class Label_Release(models.Model):
bgneal@1 296 record_label = models.ForeignKey(Record_Label)
bgneal@1 297 album = models.ForeignKey(Album)
bgneal@1 298 catalog_number = models.CharField(max_length = 32)
bgneal@1 299 release_date = models.DateField()
bgneal@1 300
bgneal@1 301 def __unicode__(self):
bgneal@1 302 return u'%s %s %s' % (self.record_label.name, self.album.title, self.catalog_number)
bgneal@1 303
bgneal@1 304 class Meta:
bgneal@1 305 verbose_name = 'Label Release'
bgneal@1 306
bgneal@1 307 #######################################################################
bgneal@1 308
bgneal@1 309 class Album_Merchant(models.Model):
bgneal@1 310 album = models.ForeignKey(Album)
bgneal@1 311 name = models.CharField(max_length = 64)
bgneal@1 312 url = models.URLField(verify_exists = False, max_length = 200)
bgneal@1 313
bgneal@1 314 def __unicode__(self):
bgneal@1 315 return u'%s (%s)' % (self.name, self.album.title)
bgneal@1 316
bgneal@1 317 class Meta:
bgneal@1 318 verbose_name = 'Album Merchant'
bgneal@1 319 ordering = ('name', )
bgneal@1 320
bgneal@1 321 #######################################################################
bgneal@1 322
bgneal@1 323 class Merchandise(models.Model):
bgneal@1 324 name = models.CharField(max_length = 64)
bgneal@1 325 desc = models.TextField()
bgneal@1 326 price = models.DecimalField(max_digits = 5, decimal_places = 2)
bgneal@1 327 in_stock = models.BooleanField()
bgneal@1 328 photo = models.ForeignKey(Photo)
bgneal@1 329
bgneal@1 330 def __unicode__(self):
bgneal@1 331 return self.name
bgneal@1 332
bgneal@1 333 class Meta:
bgneal@1 334 verbose_name_plural = "Merchandise"
bgneal@1 335
bgneal@1 336 #######################################################################
bgneal@1 337
bgneal@1 338 class Fan(models.Model):
bgneal@1 339 statusCodes = (('P', 'Pending'), ('A', 'Active'), ('L', 'Leaving'))
bgneal@1 340 keyLength = 16
bgneal@1 341
bgneal@1 342 name = models.CharField(max_length = 32, blank = True)
bgneal@1 343 email = models.EmailField(db_index = True)
bgneal@1 344 location = models.CharField(max_length = 64, blank = True)
bgneal@1 345 status = models.CharField(max_length = 1, choices = statusCodes, default = 'A',
bgneal@1 346 editable = False, db_index = True)
bgneal@1 347 key = models.CharField(max_length = keyLength, editable = False, blank = True, db_index = True)
bgneal@1 348 status_date = models.DateField(default = datetime.date.today, editable = False, db_index = True)
bgneal@1 349
bgneal@1 350 def __unicode__(self):
bgneal@1 351 if self.name:
bgneal@1 352 return u'%s <%s>' % (self.name, self.email)
bgneal@1 353 return self.email
bgneal@1 354
bgneal@1 355 class Meta:
bgneal@1 356 ordering = ('name', 'email')
bgneal@1 357
bgneal@1 358 def setPending(self):
bgneal@1 359 self.status = 'P'
bgneal@1 360 self.status_date = datetime.date.today()
bgneal@1 361 self.genKey()
bgneal@1 362
bgneal@1 363 def setActive(self):
bgneal@1 364 self.status = 'A'
bgneal@1 365 self.status_date = datetime.date.today()
bgneal@1 366
bgneal@1 367 def setLeaving(self):
bgneal@1 368 self.status = 'L'
bgneal@1 369 self.status_date = datetime.date.today()
bgneal@1 370 self.genKey()
bgneal@1 371
bgneal@1 372 def isPending(self):
bgneal@1 373 return self.status == 'P'
bgneal@1 374
bgneal@1 375 def isLeaving(self):
bgneal@1 376 return self.status == 'L'
bgneal@1 377
bgneal@1 378 def isActive(self):
bgneal@1 379 return self.status == 'A'
bgneal@1 380
bgneal@1 381 def current_status(self):
bgneal@1 382 if self.status == 'P':
bgneal@1 383 return 'Pending'
bgneal@1 384 elif self.status == 'L':
bgneal@1 385 return 'Leaving'
bgneal@1 386 elif self.status == 'A':
bgneal@1 387 return 'Active'
bgneal@1 388 else:
bgneal@1 389 return 'Unknown'
bgneal@1 390
bgneal@1 391 def genKey(self):
bgneal@1 392 self.key = ''.join(random.sample(string.ascii_letters + string.digits, self.keyLength))
bgneal@1 393