Add migrations files

This commit is contained in:
zemal 2017-05-09 14:47:54 +08:00
parent b05f864106
commit 4733eecef9
5 changed files with 42 additions and 5 deletions

View File

@ -8,6 +8,7 @@ class AdminType(object):
ADMIN = "Admin"
SUPER_ADMIN = "Super Admin"
class ProblemPermission(object):
NONE = "None"
OWN = "Own"

View File

@ -1,4 +1,3 @@
import time
import json
import requests
import hashlib
@ -12,9 +11,8 @@ from django_redis import get_redis_connection
from judge.languages import languages
from account.models import User, UserProfile
from conf.models import JudgeServer, JudgeServerToken
from contest.models import Contest
from problem.models import Problem, ProblemRuleType
from submission.models import Submission, JudgeStatus
from submission.models import JudgeStatus
logger = logging.getLogger(__name__)

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2017-05-09 06:41
from __future__ import unicode_literals
from django.db import migrations, models
import jsonfield.fields
import utils.models
import utils.shortcuts
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Submission',
fields=[
('id', models.CharField(db_index=True, default=utils.shortcuts.rand_str, max_length=32, primary_key=True, serialize=False)),
('contest_id', models.IntegerField(db_index=True, null=True)),
('problem_id', models.IntegerField(db_index=True)),
('created_time', models.DateTimeField(auto_now_add=True)),
('user_id', models.IntegerField(db_index=True)),
('code', utils.models.RichTextField()),
('result', models.IntegerField(default=6)),
('info', jsonfield.fields.JSONField(default={})),
('language', models.CharField(max_length=20)),
('shared', models.BooleanField(default=False)),
('accepted_time', models.IntegerField(blank=True, null=True)),
('accepted_info', jsonfield.fields.JSONField(default={})),
],
options={
'db_table': 'submission',
},
),
]

View File

View File

@ -5,7 +5,6 @@ from account.decorators import login_required
from account.models import AdminType, User
from problem.models import Problem
from utils.api import CSRFExemptAPIView
from utils.api import APIView, validate_serializer
from utils.shortcuts import build_query_string
from utils.throttling import TokenBucket, BucketController
@ -40,7 +39,7 @@ def _submit_code(response, user, problem_id, language, code):
try:
_judge.delay(submission, problem)
except Exception as e:
except Exception:
return response.error("Failed")
return response.success({"submission_id": submission.id})