From: David ‘Bombe’ Roden Date: Wed, 8 May 2013 23:05:22 +0000 (+0200) Subject: Extend models. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d85faf34765c823ac7f5111219b88667c0f245a8;p=demoscenemusic.git Extend models. --- diff --git a/data/models.py b/data/models.py index 7083561..33cae30 100644 --- a/data/models.py +++ b/data/models.py @@ -1,15 +1,62 @@ +# encoding: utf-8 from django.db import models +class Group(models.Model): + name = models.CharField(max_length = 80) + shortName = models.CharField(max_length = 50, blank = True) + website = models.CharField(max_length = 150, blank = True) + + def __unicode__(self): + return self.name + (' (' + self.website + ')' if (self.website != '') else '') + class Artist(models.Model): name = models.CharField(max_length = 80) + realName = models.CharField(max_length = 80, blank = True) + groups = models.ManyToManyField(Group) def __unicode__(self): - return name + return self.name -class Group(models.Model): +class Party(models.Model): + name = models.CharField(max_length = 80) + website = models.CharField(max_length = 150, blank = True) + + def __unicode__(self): + return self.name + +class Compo(models.Model): name = models.CharField(max_length = 80) - website = models.CharField(max_length = 150) + + def __unicode__(self): + return self.name; + +class Release(models.Model): + party = models.ForeignKey(Party) + year = models.IntegerField() + compo = models.ForeignKey(Compo) + place = models.IntegerField() + pouetId = models.IntegerField(blank = True) + + def __unicode__(self): + return self.compo.__unicode__() + ' @ ' + self.party.__unicode__() + ' ' + '%d' % self.year + +class Track(models.Model): + name = models.CharField(max_length = 150) artists = models.ManyToManyField(Artist) + remix = models.CharField(max_length = 80, blank = True) + remixArtists = models.ManyToManyField(Artist, related_name = 'remixTracks', blank = True) + releases = models.ManyToManyField(Release) + length = models.IntegerField() + soundcloudLink = models.CharField(max_length = 150, blank = True) + + def __unicode__(self): + #return '%s – %s%s' % (' & '.join(self.artists), self.name, (('%s by %s' % (self.remix, ' & '.join(self.remixArtists) + ')')) if (self.remix != '') else '')) + return u'{1} – {0}'.format(self.name, ' & '.join(a.name for a in self.artists.all())) + +class File(models.Model): + track = models.ForeignKey(Track) + path = models.CharField(max_length = 150) + type = models.CharField(max_length = 50) def __unicode__(self): - return self.name + ' (' + self.website + ')' + return self.type + ' (' + self.path + ')'