Ejemplo n.º 1
0
import os
from flask import Flask, Blueprint, render_template, request, url_for, redirect
import logging, random, string
from flask_login import login_user, current_user, LoginManager
from operator import getitem
import datetime as dt
from models import Contest, Account, Problem, Submission
import utils, json
from exts import db
from judger import judge, manage

log = logging.getLogger('Contest')

contest_page = Blueprint('contest_page',
                         __name__,
                         template_folder=os.path.join(utils.cur_path(__file__),
                                                      'templates'),
                         static_folder=os.path.join(utils.cur_path(__file__),
                                                    'static'),
                         static_url_path='/contest/static')
# TODO: ?????


def gen_random_str(size=4):
    return ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(size))


@contest_page.route('/contest/list', methods=['GET'])
def contest_list_view():
Ejemplo n.º 2
0
from flask import Flask, Blueprint, render_template, request, redirect, url_for
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, IntegerField, TextAreaField, SelectField, RadioField, SelectMultipleField, validators
import os, datetime, logging

# oj
import utils

log = logging.getLogger('test')

test_page = Blueprint('test_page'
					, __name__
					, template_folder=os.path.join(utils.cur_path(__file__), 'templates'))

@test_page.route('/test/rejudge/<int:subid>', methods=['GET'])
def test_rejudge(subid):
	import judger_utils
	judger_utils.rejudge(subid)
	return redirect(url_for('submissions_page.submissions_handle'))
Ejemplo n.º 3
0
from flask import Flask, Blueprint, render_template, request, flash, redirect, url_for
from flask_login import login_required, current_user
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField
from wtforms.validators import DataRequired
import os, json

import utils
from models import Problem, Account, Tag
from exts import db

edit_problem_page = Blueprint('edit_problem_page',
                              __name__,
                              template_folder=os.path.join(
                                  utils.cur_path(__file__), 'templates'))


class EditProblemForm(FlaskForm):
    problem_name = StringField('problemName',
                               validators=[DataRequired(message='題目名稱不能為空')])
    tags = StringField('tags')
    description = TextAreaField('description')
    input_format = TextAreaField('inputFormat')
    output_format = TextAreaField('outputFormat')
    sample_input = TextAreaField('sampleInput')
    sample_output = TextAreaField('sampleOutput')


# TODO(roy4801): handle the other data (hint, source, td_description, td_num)
@edit_problem_page.route('/problem_edit/<int:pid>', methods=['GET', 'POST'])
@login_required