mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 16:41:56 +00:00
Merge branch 'dev' into sxw-dev
This commit is contained in:
commit
837f721512
@ -0,0 +1 @@
|
||||
# coding=utf-8
|
1
judge/controller/README.md
Normal file
1
judge/controller/README.md
Normal file
@ -0,0 +1 @@
|
||||
celery -A judge.controller worker -l DEBUG
|
1
judge/controller/__init__.py
Normal file
1
judge/controller/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# coding=utf-8
|
5
judge/controller/celery.py
Normal file
5
judge/controller/celery.py
Normal file
@ -0,0 +1,5 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
from celery import Celery
|
||||
|
||||
app = Celery("judge", broker="redis://localhost:6379/0", include=["judge.controller.tasks"])
|
8
judge/controller/tasks.py
Normal file
8
judge/controller/tasks.py
Normal file
@ -0,0 +1,8 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
from judge.controller.celery import app
|
||||
|
||||
|
||||
@app.task
|
||||
def judge(source_code, language, test_case_id):
|
||||
print source_code, language, test_case_id
|
0
judge/judger/__init__.py
Normal file
0
judge/judger/__init__.py
Normal file
@ -11,7 +11,7 @@ from group.views import GroupAdminAPIView
|
||||
from admin.views import AdminTemplateView
|
||||
|
||||
from problem.views import ProblemAdminAPIView
|
||||
from problem.views import TestCaseUploadAPIView
|
||||
from problem.views import TestCaseUploadAPIView, ProblemTagAdminAPIView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
@ -41,4 +41,5 @@ urlpatterns = [
|
||||
url(r'^api/admin/group/$', GroupAdminAPIView.as_view(), name="group_admin_api"),
|
||||
url(r'^api/admin/problem/$', ProblemAdminAPIView.as_view(), name="problem_admin_api"),
|
||||
url(r'^api/admin/test_case_upload/$', TestCaseUploadAPIView.as_view(), name="test_case_upload_api"),
|
||||
url(r'^api/admin/tag/$', ProblemTagAdminAPIView.as_view(), name="problem_tag_admin_api"),
|
||||
]
|
||||
|
18
problem/migrations/0002_remove_problemtag_description.py
Normal file
18
problem/migrations/0002_remove_problemtag_description.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='problemtag',
|
||||
name='description',
|
||||
),
|
||||
]
|
@ -6,7 +6,7 @@ from account.models import User
|
||||
|
||||
class ProblemTag(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
description = models.CharField(max_length=50)
|
||||
# description = models.CharField(max_length=50)
|
||||
|
||||
class Meta:
|
||||
db_table = "problem_tag"
|
||||
|
@ -4,7 +4,7 @@ import json
|
||||
from rest_framework import serializers
|
||||
|
||||
from account.models import User
|
||||
from .models import Problem
|
||||
from .models import Problem, ProblemTag
|
||||
|
||||
|
||||
class ProblemSampleSerializer(serializers.ListField):
|
||||
@ -60,3 +60,12 @@ class EditProblemSerializer(serializers.Serializer):
|
||||
hint = serializers.CharField(max_length=10000)
|
||||
visible = serializers.BooleanField()
|
||||
|
||||
|
||||
|
||||
class ProblemTagSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ProblemTag
|
||||
|
||||
|
||||
class CreateProblemTagSerializer(serializers.Serializer):
|
||||
name = serializers.CharField(max_length=10)
|
@ -11,10 +11,36 @@ from django.db.models import Q
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from utils.shortcuts import serializer_invalid_response, error_response, success_response, paginate, rand_str
|
||||
from .serizalizers import CreateProblemSerializer, EditProblemSerializer, ProblemSerializer
|
||||
from .serizalizers import (CreateProblemSerializer, EditProblemSerializer, ProblemSerializer,
|
||||
ProblemTagSerializer, CreateProblemTagSerializer)
|
||||
from .models import Problem, ProblemTag
|
||||
|
||||
|
||||
class ProblemTagAdminAPIView(APIView):
|
||||
def post(self, request):
|
||||
"""
|
||||
创建标签的接口
|
||||
---
|
||||
request_serializer: CreateProblemTagSerializer
|
||||
"""
|
||||
serializer = CreateProblemTagSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
try:
|
||||
tag = ProblemTag.objects.get(name=serializer.data["name"])
|
||||
except ProblemTag.DoesNotExist:
|
||||
tag = ProblemTag.objects.create(name=serializer.data["name"])
|
||||
return success_response(ProblemTagSerializer(tag).data)
|
||||
else:
|
||||
return error_response(serializer)
|
||||
|
||||
def get(self, request):
|
||||
keyword = request.GET.get("keyword", None)
|
||||
if not keyword:
|
||||
return error_response(u"参数错误")
|
||||
tags = ProblemTag.objects.filter(name__contains=keyword)
|
||||
return success_response(ProblemTagSerializer(tags, many=True).data)
|
||||
|
||||
|
||||
|
||||
|
||||
def problem_page(request, problem_id):
|
||||
|
Loading…
Reference in New Issue
Block a user