2008-07-19 07:54:34 +08:00
|
|
|
from django.db import models
|
2009-01-16 23:32:31 +08:00
|
|
|
from django.contrib.auth.models import User
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2010-11-23 05:55:29 +08:00
|
|
|
|
|
|
|
class MyFileField(models.FileField):
|
|
|
|
pass
|
2009-04-09 04:25:56 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class Member(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
2009-01-16 23:32:31 +08:00
|
|
|
birthdate = models.DateTimeField(blank=True, null=True)
|
|
|
|
gender = models.CharField(max_length=1, blank=True, choices=[('M','Male'), ('F', 'Female')])
|
2008-09-02 06:43:38 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Band(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
members = models.ManyToManyField(Member)
|
2008-09-02 06:43:38 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Album(models.Model):
|
|
|
|
band = models.ForeignKey(Band)
|
|
|
|
name = models.CharField(max_length=100)
|
2008-08-09 07:06:28 +08:00
|
|
|
cover_art = models.FileField(upload_to='albums')
|
2009-04-09 04:25:56 +08:00
|
|
|
backside_art = MyFileField(upload_to='albums_back', null=True)
|
2008-09-02 06:43:38 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2008-11-15 10:20:00 +08:00
|
|
|
class HiddenInventoryManager(models.Manager):
|
|
|
|
def get_query_set(self):
|
2009-01-17 05:18:21 +08:00
|
|
|
return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
|
2008-11-15 10:20:00 +08:00
|
|
|
|
2008-09-02 06:43:38 +08:00
|
|
|
class Inventory(models.Model):
|
|
|
|
barcode = models.PositiveIntegerField(unique=True)
|
|
|
|
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
|
|
|
|
name = models.CharField(blank=False, max_length=20)
|
2008-11-15 10:20:00 +08:00
|
|
|
hidden = models.BooleanField(default=False)
|
2009-01-17 05:18:21 +08:00
|
|
|
|
2008-11-15 10:20:00 +08:00
|
|
|
# see #9258
|
|
|
|
default_manager = models.Manager()
|
|
|
|
objects = HiddenInventoryManager()
|
2008-09-02 06:43:38 +08:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
2009-01-17 05:18:21 +08:00
|
|
|
|
2009-01-16 23:32:31 +08:00
|
|
|
class Event(models.Model):
|
2010-03-09 02:32:24 +08:00
|
|
|
band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0))
|
2009-01-17 05:18:21 +08:00
|
|
|
start_date = models.DateField(blank=True, null=True)
|
2009-01-16 23:32:31 +08:00
|
|
|
start_time = models.TimeField(blank=True, null=True)
|
|
|
|
description = models.TextField(blank=True)
|
|
|
|
link = models.URLField(blank=True)
|
|
|
|
min_age = models.IntegerField(blank=True, null=True)
|
|
|
|
|
|
|
|
class Car(models.Model):
|
|
|
|
owner = models.ForeignKey(User)
|
|
|
|
make = models.CharField(max_length=30)
|
|
|
|
model = models.CharField(max_length=30)
|
2009-01-17 05:18:21 +08:00
|
|
|
|
2009-01-16 23:32:31 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return u"%s %s" % (self.make, self.model)
|
|
|
|
|
|
|
|
class CarTire(models.Model):
|
|
|
|
"""
|
|
|
|
A single car tire. This to test that a user can only select their own cars.
|
|
|
|
"""
|
|
|
|
car = models.ForeignKey(Car)
|