class Event models Model variables NEW PROCCESS CLOSED STATUS NEW New

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Event(models.Model):
#variables
NEW = 0
PROCCESS = 1
CLOSED = 2
STATUS = ((NEW, (_(u"New"))), (PROCCESS, _(u"In proccess")), (CLOSED, _(u"Closed")))
#fields
slug = models.SlugField(max_length=100, editable=False)
league = models.ForeignKey(League)
home = models.ForeignKey(Team, related_name='home_set', blank=lambda self: True if self.id else False)
away = models.ForeignKey(Team, related_name='away_set')
home_score = models.PositiveIntegerField()
away_score = models.PositiveIntegerField()
date = models.DateTimeField()
status = models.IntegerField(choices=STATUS)
def __unicode__(self):
return "%s - %s" % (self.home.title, self.away.title)
def save(self):
if not self.id:
self.slug = translit.slugify("%s %s %s %s %s" % (self.date.year, self.date.month, self.date.day, self.home.title, self.away.title))
super(Event, self).save()