From 16cb4ab2ca0a97ff7791d4419eb478f6d52740ab Mon Sep 17 00:00:00 2001 From: Ian Adam Naval Date: Fri, 31 Oct 2014 19:25:21 -0400 Subject: [PATCH] [#10] [#12] Add Team and Player model --- goatctf/core/models.py | 14 +++++++++++++- goatctf/core/settings.py | 1 + requirements.txt | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/goatctf/core/models.py b/goatctf/core/models.py index 19fdda3..b0ae6b0 100644 --- a/goatctf/core/models.py +++ b/goatctf/core/models.py @@ -1,5 +1,6 @@ +from django.contrib.auth.models import User from django.db import models -from core.settings import FLAG_LENGTH +from core.settings import TEAM_NAME_LENGTH, FLAG_LENGTH class Challenge(models.Model): @@ -9,3 +10,14 @@ class Challenge(models.Model): flag = models.CharField(max_length=FLAG_LENGTH) description_markdown = models.TextField() description_html = models.TextField() + + +class Team(models.Model): + """A team is a collection of players.""" + name = models.CharField(max_length=TEAM_NAME_LENGTH) + creator = models.ForeignKey("Player", related_name="created_teams") + + +class Player(User): + """A player is a user with a team.""" + team = models.ForeignKey("Team") diff --git a/goatctf/core/settings.py b/goatctf/core/settings.py index f623462..8ed09e8 100644 --- a/goatctf/core/settings.py +++ b/goatctf/core/settings.py @@ -1 +1,2 @@ FLAG_LENGTH = 256 +TEAM_NAME_LENGTH = 64 diff --git a/requirements.txt b/requirements.txt index 2f2e6fa..f7c9c8e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Django==1.7.1 \ No newline at end of file +Django==1.7.1 +django-gravatar2==1.1.4 \ No newline at end of file