Merge branch 'zemal_dev'
This commit is contained in:
@@ -9,6 +9,11 @@ location /api {
|
|||||||
client_max_body_size 200M;
|
client_max_body_size 200M;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /data/ {
|
||||||
|
internal;
|
||||||
|
alias /data/; # note that trailing slash
|
||||||
|
}
|
||||||
|
|
||||||
location /admin {
|
location /admin {
|
||||||
root /app/dist/admin;
|
root /app/dist/admin;
|
||||||
try_files $uri $uri/ /index.html =404;
|
try_files $uri $uri/ /index.html =404;
|
||||||
@@ -17,4 +22,4 @@ location /admin {
|
|||||||
location / {
|
location / {
|
||||||
root /app/dist;
|
root /app/dist;
|
||||||
try_files $uri $uri/ /index.html =404;
|
try_files $uri $uri/ /index.html =404;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,14 @@ _cpp_lang_spj_config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_java_lang_config = {
|
_java_lang_config = {
|
||||||
"template": """/*--PREPEND START--*/
|
"template": """//PREPEND BEGIN
|
||||||
/*--PREPEND END--*/
|
//PREPEND END
|
||||||
/*--TEMPLATE BEGIN--*/
|
|
||||||
/*--TEMPLATE END--*/
|
//TEMPLATE BEGIN
|
||||||
/*--APPEND START--*/
|
//TEMPLATE END
|
||||||
/*--APPEND END--*/""",
|
|
||||||
|
//APPEND BEGIN
|
||||||
|
//APPEND END""",
|
||||||
"compile": {
|
"compile": {
|
||||||
"src_name": "Main.java",
|
"src_name": "Main.java",
|
||||||
"exe_name": "Main",
|
"exe_name": "Main",
|
||||||
@@ -119,12 +121,14 @@ _java_lang_config = {
|
|||||||
|
|
||||||
|
|
||||||
_py2_lang_config = {
|
_py2_lang_config = {
|
||||||
"template": """/*--PREPEND START--*/
|
"template": """//PREPEND BEGIN
|
||||||
/*--PREPEND END--*/
|
//PREPEND END
|
||||||
/*--TEMPLATE BEGIN--*/
|
|
||||||
/*--TEMPLATE END--*/
|
//TEMPLATE BEGIN
|
||||||
/*--APPEND START--*/
|
//TEMPLATE END
|
||||||
/*--APPEND END--*/""",
|
|
||||||
|
//APPEND BEGIN
|
||||||
|
//APPEND END""",
|
||||||
"compile": {
|
"compile": {
|
||||||
"src_name": "solution.py",
|
"src_name": "solution.py",
|
||||||
"exe_name": "solution.pyc",
|
"exe_name": "solution.pyc",
|
||||||
@@ -139,6 +143,14 @@ _py2_lang_config = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_py3_lang_config = {
|
_py3_lang_config = {
|
||||||
|
"template": """//PREPEND BEGIN
|
||||||
|
//PREPEND END
|
||||||
|
|
||||||
|
//TEMPLATE BEGIN
|
||||||
|
//TEMPLATE END
|
||||||
|
|
||||||
|
//APPEND BEGIN
|
||||||
|
//APPEND END""",
|
||||||
"compile": {
|
"compile": {
|
||||||
"src_name": "solution.py",
|
"src_name": "solution.py",
|
||||||
"exe_name": "__pycache__/solution.cpython-35.pyc",
|
"exe_name": "__pycache__/solution.cpython-35.pyc",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import zipfile
|
|||||||
from wsgiref.util import FileWrapper
|
from wsgiref.util import FileWrapper
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import StreamingHttpResponse
|
from django.http import StreamingHttpResponse, HttpResponse
|
||||||
|
|
||||||
from account.decorators import problem_permission_required
|
from account.decorators import problem_permission_required
|
||||||
from judge.dispatcher import SPJCompiler
|
from judge.dispatcher import SPJCompiler
|
||||||
@@ -67,8 +67,14 @@ class TestCaseAPI(CSRFExemptAPIView):
|
|||||||
with zipfile.ZipFile(file_name, "w") as file:
|
with zipfile.ZipFile(file_name, "w") as file:
|
||||||
for test_case in name_list:
|
for test_case in name_list:
|
||||||
file.write(f"{test_case_dir}/{test_case}", test_case)
|
file.write(f"{test_case_dir}/{test_case}", test_case)
|
||||||
response = StreamingHttpResponse(FileWrapper(open(file_name, "rb")), content_type="application/zip")
|
if os.environ.get("OJ_ENV") == "production":
|
||||||
|
response = HttpResponse()
|
||||||
|
response["X-Accel-Redirect"] = file_name
|
||||||
|
else:
|
||||||
|
response = StreamingHttpResponse(FileWrapper(open(file_name, "rb")), content_type="application/octet-stream")
|
||||||
|
|
||||||
response["Content-Disposition"] = f"attachment; filename=problem_{problem.id}_test_cases.zip"
|
response["Content-Disposition"] = f"attachment; filename=problem_{problem.id}_test_cases.zip"
|
||||||
|
response["Content-Length"] = os.path.getsize(file_name)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@problem_permission_required
|
@problem_permission_required
|
||||||
|
|||||||
Reference in New Issue
Block a user