2009-05-14 15:09:33 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2012-04-29 09:51:12 +00:00
|
|
|
class Event(models.Model):
|
|
|
|
date = models.DateField()
|
2011-10-13 18:51:33 +00:00
|
|
|
|
2009-05-14 15:09:33 +00:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
|
|
|
|
class Child(models.Model):
|
2011-01-24 07:01:00 +00:00
|
|
|
parent = models.ForeignKey(Parent, editable=False, null=True)
|
|
|
|
name = models.CharField(max_length=30, blank=True)
|
2011-10-26 12:19:18 +00:00
|
|
|
age = models.IntegerField(null=True, blank=True)
|
2011-02-13 22:51:40 +00: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)
|
2011-11-17 21:30:07 +00:00
|
|
|
|
|
|
|
class Swallow(models.Model):
|
|
|
|
origin = models.CharField(max_length=255)
|
|
|
|
load = models.FloatField()
|
|
|
|
speed = models.FloatField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('speed', 'load')
|
2012-03-03 02:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UnorderedObject(models.Model):
|
|
|
|
"""
|
|
|
|
Model without any defined `Meta.ordering`.
|
|
|
|
Refs #17198.
|
|
|
|
"""
|
|
|
|
bool = models.BooleanField(default=True)
|
|
|
|
|
|
|
|
|
|
|
|
class OrderedObjectManager(models.Manager):
|
|
|
|
def get_query_set(self):
|
2012-04-09 04:28:32 +00:00
|
|
|
return super(OrderedObjectManager, self).get_query_set().order_by('number')
|
2012-03-03 02:13:35 +00:00
|
|
|
|
|
|
|
class OrderedObject(models.Model):
|
|
|
|
"""
|
|
|
|
Model with Manager that defines a default order.
|
|
|
|
Refs #17198.
|
|
|
|
"""
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
bool = models.BooleanField(default=True)
|
2012-03-19 12:52:15 +00:00
|
|
|
number = models.IntegerField(default=0, db_column='number_val')
|
2012-03-03 02:13:35 +00:00
|
|
|
|
2012-03-19 12:52:15 +00:00
|
|
|
objects = OrderedObjectManager()
|