Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tournaments application and models for it
- Loading branch information
Andrey Niakhaichyk
committed
May 21, 2013
1 parent
27fc24d
commit eb194d0
Showing
6 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Player(models.Model): | ||
name = models.CharField(max_length=200) | ||
register_date = models.DateTimeField('registration date') | ||
initial_rating = models.IntegerField() | ||
rating = models.IntegerField() | ||
fide_id = models.BigIntegerField('FIDE ID') | ||
fide_title = models.CharField(max_length=10) | ||
|
||
class Tournament(models.Model): | ||
name = models.CharField(max_length=200) | ||
start_date = models.DateTimeField() | ||
end_date = models.DateTimeField() | ||
players = models.ManyToManyField(Player) | ||
|
||
class Round(models.Model): | ||
tournament = models.ForeignKey(Tournament) | ||
name = models.CharField(max_length=200) | ||
round_date = models.DateTimeField() | ||
|
||
class Game(models.Model): | ||
GAME_STATUSES = ( | ||
('planned', 'planned'), | ||
('finished', 'finished'), | ||
('walkover', 'walkover'), | ||
) | ||
|
||
round = models.ForeignKey(Round) | ||
player = models.ForeignKey(Player, related_name="player_a") | ||
player_score = models.DecimalField(max_digits=4, decimal_places=1) | ||
opponent = models.ForeignKey(Player, related_name="player_b") | ||
opponent_score = models.DecimalField(max_digits=4, decimal_places=1) | ||
status = models.CharField(max_length=10, | ||
choices=GAME_STATUSES, | ||
default='planned') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this with more appropriate tests for your application. | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
|
||
class SimpleTest(TestCase): | ||
def test_basic_addition(self): | ||
""" | ||
Tests that 1 + 1 always equals 2. | ||
""" | ||
self.assertEqual(1 + 1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Create your views here. |