Add DuckCompetence model

This commit is contained in:
Gergely Polonkai 2014-12-22 14:28:03 +01:00 committed by Gergely Polonkai
parent d7feab58fe
commit 6b0cdfdde7

View File

@ -35,6 +35,7 @@ class Duck(models.Model):
color = models.CharField(max_length = 6) color = models.CharField(max_length = 6)
species = models.ForeignKey(Species) species = models.ForeignKey(Species)
location = models.ForeignKey(Location) location = models.ForeignKey(Location)
comps = models.ManyToManyField(Competence, through = 'DuckCompetence')
donated_by = models.ForeignKey(User) donated_by = models.ForeignKey(User)
donated_at = models.DateTimeField(default = timezone.now) donated_at = models.DateTimeField(default = timezone.now)
adopted_by = models.ForeignKey(User, related_name = 'adopted_ducks', null = True) adopted_by = models.ForeignKey(User, related_name = 'adopted_ducks', null = True)
@ -47,3 +48,14 @@ class Duck(models.Model):
return 'Unnamed :(' return 'Unnamed :('
return self.name return self.name
class DuckCompetence(models.Model):
"""Duck competence governor table"""
duck = models.ForeignKey(Duck)
comp = models.ForeignKey(Competence)
up_minutes = models.IntegerField(default = 0)
down_minutes = models.IntegerField(default = 0)
class Meta:
unique_together = ('duck', 'comp')