2009-05-14 23:09:33 +08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
|
|
|
|
class Child(models.Model):
|
2011-01-24 15:01:00 +08:00
|
|
|
parent = models.ForeignKey(Parent, editable=False, null=True)
|
|
|
|
name = models.CharField(max_length=30, blank=True)
|
2011-02-14 06:51:40 +08:00
|
|
|
|
|
|
|
class Genre(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
|
|
|
|
class Band(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
nr_of_members = models.PositiveIntegerField()
|
|
|
|
genres = models.ManyToManyField(Genre)
|
|
|
|
|
|
|
|
class Musician(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Group(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
members = models.ManyToManyField(Musician, through='Membership')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Membership(models.Model):
|
|
|
|
music = models.ForeignKey(Musician)
|
|
|
|
group = models.ForeignKey(Group)
|
|
|
|
role = models.CharField(max_length=15)
|
|
|
|
|
|
|
|
class Quartet(Group):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class ChordsMusician(Musician):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class ChordsBand(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
members = models.ManyToManyField(ChordsMusician, through='Invitation')
|
|
|
|
|
|
|
|
class Invitation(models.Model):
|
|
|
|
player = models.ForeignKey(ChordsMusician)
|
|
|
|
band = models.ForeignKey(ChordsBand)
|
|
|
|
instrument = models.CharField(max_length=15)
|