Skip to content

Commit

Permalink
Tournaments application and models for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Niakhaichyk committed May 21, 2013
1 parent 27fc24d commit eb194d0
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -4,9 +4,11 @@ swiss-system-chess-tournament
The system is for helping judges to provide chess tournaments based on swiss system.

#### Requirements:
Python 2.7
Django 1.5.1
* Python 2.7
* Django 1.5.1

#### Features:


#### Problems:
* How to store players for game? One record or two record?
1 change: 1 addition & 0 deletions ss_chess_tour/settings.py
Expand Up @@ -124,6 +124,7 @@
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'tournaments',
)

# A sample logging configuration. The only tangible logging
Expand Down
Empty file added tournaments/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions tournaments/models.py
@@ -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')

16 changes: 16 additions & 0 deletions tournaments/tests.py
@@ -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)
1 change: 1 addition & 0 deletions tournaments/views.py
@@ -0,0 +1 @@
# Create your views here.

0 comments on commit eb194d0

Please sign in to comment.