Add category to Problems

This commit is contained in:
James Wang 2016-01-01 23:18:40 -05:00
parent f412840df8
commit c6b6766e6b
2 changed files with 5 additions and 2 deletions

View file

@ -37,6 +37,7 @@ class Teams(db.Model):
class Problems(db.Model):
pid = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128))
category = db.Column(db.String(128))
description = db.Column(db.Text)
hint = db.Column(db.Text)
flag = db.Column(db.Text)
@ -44,8 +45,9 @@ class Problems(db.Model):
value = db.Column(db.Integer)
solves = db.Column(db.Integer)
def __init__(self, name, description, hint, flag, value):
def __init__(self, name, category, description, hint, flag, value):
self.name = name
self.category = category
self.description = description
self.hint = hint
self.flag = flag

View file

@ -11,6 +11,7 @@ blueprint = Blueprint("problem", __name__)
@api_wrapper
def problem_add():
name = request.form["name"]
category = request.form["category"]
description = request.form["description"]
hint = request.form["hint"]
flag = request.form["flag"]
@ -21,7 +22,7 @@ def problem_add():
if name_exists:
return { "success":0, "message": "Problem name already taken." }
problem = Problems(name, description, hint, flag, value)
problem = Problems(name, category, description, hint, flag, value)
db.session.add(problem)
db.session.commit()