Model setup for foozball

Python

Public Domain

for a webapp i'm working on

Download (right click, save as, rename as appropriate)

Embed

Tags:

django python
 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from django.db import models

# Create your models here.

class Division(models.Model):
    div_id   = models.IntegerField(primary_key=True)
    division = models.CharField(max_length=15)
    
class Games(models.Model):
    game_id     = models.IntegerField(primary_key=True)
    opp_id_1    = models.IntegerField()
    opp_id_2    = models.IntegerField()
    opp_win_id  = models.IntegerField()
    opp_loss_id = models.IntegerField()
    score       = models.CharField(max_length=10)
    date        = models.DateTimeField()
    class Meta:
        verbose_name_plural = 'Games'
    
class RosterStatus(models.Model):
    roster_status_id = models.IntegerField(primary_key=True)
    status_code      = models.CharField(max_length=25)
    status_desc      = models.CharField(max_length=50)
    class Meta:
        verbose_name_plural = 'Roster Statuses'

class Teams(models.Model):
    team_id     = models.IntegerField(primary_key=True)
    name        = models.CharField(max_length=25)
    city        = models.CharField(max_length=50)
    div         = models.ForeignKey(Division)
    record_w    = models.IntegerField()
    record_l    = models.IntegerField()
    class Meta:
        ordering = ('name', 'city')
        verbose_name_plural = 'Teams'
        
    def __unicode__(self):
        return u"%s %s" % (self.city, self.team)

class Players(models.Model):
    player_id        = models.IntegerField(primary_key=True)
    firstname        = models.CharField(max_length=50)
    lastname         = models.CharField(max_length=50)
    team             = models.ForeignKey(Teams)
    Top200rank       = models.IntegerField(null=True, blank=True)
    position         = models.CharField(max_length=25)
    roster_status    = models.ForeignKey(RosterStatus, null=True, blank=True)
    class Meta:
        ordering = ('lastname', 'firstname')
        verbose_name_plural = 'Players'
        
    def __unicode__(self):
        return u"%s %s" % (self.firstname, self.last_name)