Browse Source

[#10] [#12] Add Team and Player model

Ian Adam Naval 4 years ago
parent
commit
16cb4ab2ca
3 changed files with 16 additions and 2 deletions
  1. 13
    1
      goatctf/core/models.py
  2. 1
    0
      goatctf/core/settings.py
  3. 2
    1
      requirements.txt

+ 13
- 1
goatctf/core/models.py View File

@@ -1,5 +1,6 @@
1
+from django.contrib.auth.models import User
1 2
 from django.db import models
2
-from core.settings import FLAG_LENGTH
3
+from core.settings import TEAM_NAME_LENGTH, FLAG_LENGTH
3 4
 
4 5
 
5 6
 class Challenge(models.Model):
@@ -9,3 +10,14 @@ class Challenge(models.Model):
9 10
     flag = models.CharField(max_length=FLAG_LENGTH)
10 11
     description_markdown = models.TextField()
11 12
     description_html = models.TextField()
13
+
14
+
15
+class Team(models.Model):
16
+    """A team is a collection of players."""
17
+    name = models.CharField(max_length=TEAM_NAME_LENGTH)
18
+    creator = models.ForeignKey("Player", related_name="created_teams")
19
+
20
+
21
+class Player(User):
22
+    """A player is a user with a team."""
23
+    team = models.ForeignKey("Team")

+ 1
- 0
goatctf/core/settings.py View File

@@ -1 +1,2 @@
1 1
 FLAG_LENGTH = 256
2
+TEAM_NAME_LENGTH = 64

+ 2
- 1
requirements.txt View File

@@ -1 +1,2 @@
1
-Django==1.7.1
1
+Django==1.7.1
2
+django-gravatar2==1.1.4

Loading…
Cancel
Save