2016-01-03 03:15:23 +00:00
|
|
|
from flask import Blueprint, jsonify
|
2016-01-07 00:23:43 +00:00
|
|
|
from decorators import admins_only, api_wrapper
|
2016-01-03 03:15:23 +00:00
|
|
|
from models import db, Problems, Files
|
2016-03-10 04:33:34 +00:00
|
|
|
from schemas import verify_to_schema, check
|
2015-12-24 03:51:42 +00:00
|
|
|
|
2016-01-07 00:23:43 +00:00
|
|
|
import json
|
|
|
|
|
2015-12-27 00:19:31 +00:00
|
|
|
blueprint = Blueprint("admin", __name__)
|
2016-01-03 03:15:23 +00:00
|
|
|
|
2016-01-12 03:54:26 +00:00
|
|
|
@blueprint.route("/problems/list", methods=["GET"])
|
2016-01-07 00:23:43 +00:00
|
|
|
@api_wrapper
|
2016-01-03 03:15:23 +00:00
|
|
|
@admins_only
|
|
|
|
def problem_data():
|
2016-01-07 00:23:43 +00:00
|
|
|
problems = Problems.query.order_by(Problems.value).all()
|
|
|
|
problems_return = [ ]
|
|
|
|
for problem in problems:
|
|
|
|
problems_return.append({
|
|
|
|
"pid": problem.pid,
|
|
|
|
"name": problem.name,
|
|
|
|
"category": problem.category,
|
|
|
|
"description": problem.description,
|
|
|
|
"hint": problem.hint,
|
|
|
|
"value": problem.value,
|
|
|
|
"threshold": problem.threshold,
|
|
|
|
"weightmap": json.loads(problem.weightmap)
|
|
|
|
})
|
2016-03-10 04:33:34 +00:00
|
|
|
return { "success": 1, "problems": problems_return }
|
|
|
|
|
|
|
|
"""
|
|
|
|
@blueprint.route("/problems/submit", methods=["POST"])
|
|
|
|
@api_wrapper
|
|
|
|
@admins_only
|
|
|
|
def problem_submit():
|
|
|
|
params = utils.flat_multi(request.form)
|
|
|
|
verify_to_schema(UserSchema, params)
|
|
|
|
|
|
|
|
title = params.get("title")
|
|
|
|
|
|
|
|
ProblemSubmissionSchema = Schema({
|
|
|
|
Required("title"): check(
|
|
|
|
([str, Length(min=4, max=64)], "The title should be between 4 and 64 characters long."),
|
|
|
|
),
|
|
|
|
}, extra=True)
|
|
|
|
"""
|