From c6add58ee1c500774a7573bfbe639bd4fa3cbcfd Mon Sep 17 00:00:00 2001 From: James Wang Date: Wed, 23 Dec 2015 19:40:59 -0500 Subject: [PATCH 01/18] Begin work on a few other models --- server/api/models.py | 69 +++++++++++++++++++++++++++++++++++--------- server/api/utils.py | 2 +- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/server/api/models.py b/server/api/models.py index c63243f..acc73c2 100644 --- a/server/api/models.py +++ b/server/api/models.py @@ -4,17 +4,60 @@ import utils db = SQLAlchemy() class Users(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(64)) - username = db.Column(db.String(64), unique=True) - username_lower = db.Column(db.String(64), unique=True) - email = db.Column(db.String(64), unique=True) - password = db.Column(db.String(128)) - admin = db.Column(db.Boolean) + uid = db.Column(db.Integer, primary_key=True) + tid = db.Column(db.Integer) + name = db.Column(db.String(64)) + username = db.Column(db.String(64), unique=True) + username_lower = db.Column(db.String(64), unique=True) + email = db.Column(db.String(64), unique=True) + password = db.Column(db.String(128)) + admin = db.Column(db.Boolean) - def __init__(self, name, username, email, password): - self.name = name - self.username = username - self.username_lower = username.lower() - self.email = email.lower() - self.password = utils.hash_password(password) \ No newline at end of file + def __init__(self, name, tid, username, email, password): + self.name = name + self.tid = tid + self.username = username + self.username_lower = username.lower() + self.email = email.lower() + self.password = utils.hash_password(password) + +class Teams(db.Model): + tid = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(64), unique=True) + join_code = db.Column(db.String(128), unique=True) + school = db.Column(db.String) + size = db.Column(db.Integer) + score = db.Column(db.Integer) + observer = db.Column(db.Boolean) + owner = db.Column(db.Integer) + + def __init__(self, name, school): + self.name = name + self.school = school + +class Problems(db.Model): + pid = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(128)) + description = db.Column(db.Text) + hint = db.Column(db.Text) + flag = db.Column(db.Text) + disabled = db.Column(db.Boolean) + value = db.Column(db.Integer) + solves = db.Column(db.Integer) + + def __init__(self, name, description, hint, flag, value): + self.name = name + self.description = description + self.hint = hint + self.flag = flag + self.value = value + +class Solves(db.Model): + sid = db.Column(db.Integer, primary_key=True) + pid = db.Column(db.Integer) + tid = db.Column(db.Integer) + date = db.Column(db.Integer, default=utils.get_time_since_epoch()) + + def __init__(self, pid, tid): + self.pid = pid + self.tid = tid diff --git a/server/api/utils.py b/server/api/utils.py index 8ecbd6a..f638462 100644 --- a/server/api/utils.py +++ b/server/api/utils.py @@ -40,4 +40,4 @@ def api_wrapper(f): traceback.print_exc() web_result = { "success": 0, "message": "Something went wrong! Please notify us about this immediately.", error: traceback.format_exc() } return json.dumps(web_result), response, { "Content-Type": "application/json; charset=utf-8" } - return wrapper \ No newline at end of file + return wrapper From 36bdcd5e6fdc2991cfb631338ea5d8acee798a68 Mon Sep 17 00:00:00 2001 From: James Wang Date: Wed, 23 Dec 2015 19:54:47 -0500 Subject: [PATCH 02/18] Add user blueprint to app.py --- server/api/api.py | 8 -------- server/api/user.py | 15 +++++++++++++-- server/app.py | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/server/api/api.py b/server/api/api.py index 7626508..c55788b 100644 --- a/server/api/api.py +++ b/server/api/api.py @@ -1,11 +1,3 @@ from flask import Blueprint api = Blueprint("api", __name__) - -@api.route("/api/register", methods=["POST"]) -def register(): - pass - -@api.route("/api/login", methods=["POST"]) -def login(): - pass diff --git a/server/api/user.py b/server/api/user.py index 315df69..2150358 100644 --- a/server/api/user.py +++ b/server/api/user.py @@ -1,4 +1,4 @@ -from flask import Blueprint +from flask import Blueprint, session from utils import api_wrapper blueprint = Blueprint("user", __name__) @@ -6,4 +6,15 @@ blueprint = Blueprint("user", __name__) @blueprint.route("/register", methods=["POST"]) @api_wrapper def user_register(): - return { "success": 0, "message": "Registration is not open yet." } \ No newline at end of file + return { "success": 0, "message": "Registration is not open yet." } + +@blueprint.route("/logout", methods=["POST"]) +@api_wrapper +def user_logout(): + # session.clear() + pass + +@blueprint.route("/login", methods=["POST"]) +@api_wrapper +def user_login(): + pass \ No newline at end of file diff --git a/server/app.py b/server/app.py index 9ee2124..cb2aa98 100644 --- a/server/app.py +++ b/server/app.py @@ -6,10 +6,12 @@ import json import api from api.api import api as api_blueprint +from api.user import blueprint as user_blueprint app = Flask(__name__) app.secret_key = config.SECRET app.register_blueprint(api_blueprint) +app.register_blueprint(user_blueprint) @app.route("/api") def api_main(): From c79489c4cf12b3fb64a5863d9364b977b68e5bf5 Mon Sep 17 00:00:00 2001 From: James Wang Date: Wed, 23 Dec 2015 20:12:23 -0500 Subject: [PATCH 03/18] Fix blueprint route --- server/api/user.py | 2 +- server/app.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/api/user.py b/server/api/user.py index 2150358..a9b179d 100644 --- a/server/api/user.py +++ b/server/api/user.py @@ -17,4 +17,4 @@ def user_logout(): @blueprint.route("/login", methods=["POST"]) @api_wrapper def user_login(): - pass \ No newline at end of file + pass diff --git a/server/app.py b/server/app.py index cb2aa98..785b054 100644 --- a/server/app.py +++ b/server/app.py @@ -11,7 +11,7 @@ from api.user import blueprint as user_blueprint app = Flask(__name__) app.secret_key = config.SECRET app.register_blueprint(api_blueprint) -app.register_blueprint(user_blueprint) +app.register_blueprint(user_blueprint, url_prefix="/api/user") @app.route("/api") def api_main(): @@ -33,6 +33,4 @@ if __name__ == "__main__": db.init_app(app) db.create_all() - app.register_blueprint(api.user.blueprint, url_prefix="/api/user") - app.run(host="0.0.0.0", port=8000) From 4ec972581306a9650695a432599b07ef60212ee7 Mon Sep 17 00:00:00 2001 From: Charles Truluck Date: Wed, 23 Dec 2015 20:15:13 -0500 Subject: [PATCH 04/18] Spiced up web/index.html ;) Working on other pages styling --- web/css/style.css | 9 ++++++--- web/index.html | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/web/css/style.css b/web/css/style.css index 2b150d5..cbc375b 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -1,4 +1,7 @@ -marquee { - background-color: black; - color:white; +h1 { + font-size: 75px; +} + +.intro { + text-align: center; } diff --git a/web/index.html b/web/index.html index 8fdc701..6ff44d7 100644 --- a/web/index.html +++ b/web/index.html @@ -8,12 +8,19 @@ - Angular.js Status: Failed! - + +
+
+

EasyCTF

+

Comming 2016

+
+
From 531a7c100f630c563e6e49ce5fee1d5fecee24ad Mon Sep 17 00:00:00 2001 From: Charles Truluck Date: Wed, 23 Dec 2015 20:20:07 -0500 Subject: [PATCH 05/18] Fixed NavBar Floating --- web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.html b/web/index.html index 6ff44d7..530d5c0 100644 --- a/web/index.html +++ b/web/index.html @@ -8,7 +8,7 @@ -