3eb55fb2299e5fbd999b9f5f1b53d495b131b7ed
[mlpccg-meta.git] / meta / models.py
1 from django.db import models
2
3 class DeckListModel(models.Model):
4 name = models.CharField(max_length=200)
5 url = models.URLField(max_length=500)
6
7 def __unicode__(self):
8 return self.name
9
10 class TournamentModel(models.Model):
11 name = models.CharField(max_length=200)
12 date = models.DateField()
13 verified = models.BooleanField()
14
15 def __unicode__(self):
16 return '%s (%s)' % (self.name, self.date.strftime('%Y-%m-%d'))
17
18 class RecordModel(models.Model):
19 placement = models.IntegerField()
20 tournament = models.ForeignKey(TournamentModel)
21 decklist = models.ForeignKey(DeckListModel)
22 verified = models.BooleanField()
23
24 def __unicode__(self):
25 p = str(self.placement)+("th" if 4 <= self.placement % 100 <= 20 else {1:"st",2:"nd",3:"rd"}.get(self.placement%10, "th"))
26 return '%s @ %s' % (p, self.tournament.name)