Browse Source

Merge pull request #18 from GoatCTF/dev

Add models.
Louis Fogel 4 years ago
parent
commit
957bbe147a
4 changed files with 60 additions and 2 deletions
  1. 28
    1
      goatctf/core/models.py
  2. 2
    0
      goatctf/core/settings.py
  3. 2
    1
      requirements.txt
  4. 28
    0
      setup.py

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

@@ -1,3 +1,30 @@
1
+from django.contrib.auth.models import User
1 2
 from django.db import models
3
+from core.settings import TEAM_NAME_LENGTH, FLAG_LENGTH
2 4
 
3
-# Create your models here.
5
+
6
+class Challenge(models.Model):
7
+    """A challenge represents an individual problem to be solved."""
8
+    points = models.IntegerField()
9
+    category = models.CharField(max_length=2)
10
+    flag = models.CharField(max_length=FLAG_LENGTH)
11
+    description_markdown = models.TextField()
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")
24
+
25
+
26
+class Solution(models.Model):
27
+    """A solution is a player's """
28
+    challenge = models.ForeignKey("Challenge")
29
+    solved_at = models.DateTimeField(auto_now_add=True)
30
+    solver = models.ForeignKey("Player")

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

@@ -0,0 +1,2 @@
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

+ 28
- 0
setup.py View File

@@ -0,0 +1,28 @@
1
+import os
2
+from setuptools import setup, find_packages
3
+
4
+
5
+# Utility function to read the README file.
6
+# Used for the long_description.  It's nice, because now 1) we have a top level
7
+# README file and 2) it's easier to type in the README file than to put a raw
8
+# string in below ...
9
+def read(fname):
10
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
11
+
12
+setup(
13
+    name="goatctf",
14
+    version="0.0.1",
15
+    author="WPI Cybersecurity Club",
16
+    author_email="csc@wpi.edu",
17
+    description=("A framework for running CTFs."),
18
+    license="MIT",
19
+    keywords="example documentation tutorial",
20
+    url="https://github.com/GoatCTF/GoatCTF/",
21
+    packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
22
+    long_description=read('README.md'),
23
+    classifiers=[
24
+        "Development Status :: 3 - Alpha",
25
+        "Topic :: Utilities",
26
+        "License :: OSI Approved :: MIT License",
27
+    ],
28
+)

Loading…
Cancel
Save