Add output-only on UI
This commit is contained in:
parent
bdae79eeda
commit
195450ebc3
15 changed files with 708 additions and 566 deletions
|
@ -7,6 +7,7 @@ from random import randrange
|
|||
import random
|
||||
from copy import deepcopy
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
|
@ -486,7 +487,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
orphans=orphans,
|
||||
allow_empty_first_page=allow_empty_first_page,
|
||||
count=queryset.values("pk").count() if not self.in_contest else None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
if not self.in_contest:
|
||||
queryset = queryset.add_i18n_name(self.request.LANGUAGE_CODE)
|
||||
|
@ -1039,8 +1040,10 @@ def problem_submit(request, problem, submission=None):
|
|||
if request.method == "POST":
|
||||
form = ProblemSubmitForm(
|
||||
request.POST,
|
||||
request.FILES,
|
||||
judge_choices=judge_choices,
|
||||
instance=Submission(user=profile, problem=problem),
|
||||
request=request,
|
||||
)
|
||||
if form.is_valid():
|
||||
if (
|
||||
|
@ -1114,6 +1117,7 @@ def problem_submit(request, problem, submission=None):
|
|||
|
||||
# Save a query
|
||||
model.source = source
|
||||
cache.set(f"submission_source_file:{model.id}", form.source_file_name, 3600)
|
||||
model.judge(rejudge=False, judge_id=form.cleaned_data["judge"])
|
||||
|
||||
return HttpResponseRedirect(
|
||||
|
|
|
@ -27,6 +27,7 @@ from django.forms import (
|
|||
formset_factory,
|
||||
FileInput,
|
||||
TextInput,
|
||||
CheckboxInput,
|
||||
)
|
||||
from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
@ -91,6 +92,7 @@ class ProblemDataForm(ModelForm):
|
|||
"interactive_judge",
|
||||
"fileio_input",
|
||||
"fileio_output",
|
||||
"output_only",
|
||||
]
|
||||
widgets = {
|
||||
"zipfile": FineUploadFileInput,
|
||||
|
@ -100,6 +102,7 @@ class ProblemDataForm(ModelForm):
|
|||
"output_prefix": HiddenInput,
|
||||
"fileio_input": TextInput,
|
||||
"fileio_output": TextInput,
|
||||
"output_only": CheckboxInput,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ from django.utils.translation import gettext_lazy
|
|||
from django.views.decorators.http import require_POST
|
||||
from django.views.generic import DetailView
|
||||
from django.views.generic import ListView
|
||||
from django.views import View
|
||||
|
||||
from judge import event_poster as event
|
||||
from judge.highlight_code import highlight_code
|
||||
|
@ -1049,3 +1050,16 @@ class UserContestSubmissionsAjax(UserContestSubmissions):
|
|||
return super(UserContestSubmissionsAjax, self).get(request, *args, **kwargs)
|
||||
except Http404:
|
||||
return HttpResponse(_("You don't have permission to access."))
|
||||
|
||||
|
||||
class SubmissionSourceFileView(View):
|
||||
def get(self, request, filename):
|
||||
filepath = os.path.join(settings.DMOJ_SUBMISSION_ROOT, filename)
|
||||
if not os.path.exists(filepath):
|
||||
raise Http404("File not found")
|
||||
response = HttpResponse()
|
||||
with open(filepath, "rb") as f:
|
||||
response.content = f.read()
|
||||
response["Content-Type"] = "application/octet-stream"
|
||||
response["Content-Disposition"] = "attachment; filename=%s" % (filename,)
|
||||
return response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue