From 90ea6a784415306cefca61ee1cf544001b2d377a Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sun, 26 Mar 2023 03:00:05 -0500 Subject: [PATCH] Fix scat bug --- judge/forms.py | 8 ++++++-- judge/views/problem.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/judge/forms.py b/judge/forms.py index 077728a..057b86c 100644 --- a/judge/forms.py +++ b/judge/forms.py @@ -131,10 +131,11 @@ class ProblemSubmitForm(ModelForm): judge = ChoiceField(choices=(), widget=forms.HiddenInput(), required=False) source_file = FileField(required=False, validators=[file_size_validator]) - def __init__(self, *args, judge_choices=(), request=None, **kwargs): + def __init__(self, *args, judge_choices=(), request=None, problem=None, **kwargs): super(ProblemSubmitForm, self).__init__(*args, **kwargs) self.source_file_name = None self.request = request + self.problem = problem self.fields["language"].empty_label = None self.fields["language"].label_from_instance = attrgetter("display_name") self.fields["language"].queryset = Language.objects.filter( @@ -149,7 +150,10 @@ class ProblemSubmitForm(ModelForm): def clean(self): if "source_file" in self.files: - if self.cleaned_data["language"].key in ["OUTPUT", "SCAT"]: + if ( + self.cleaned_data["language"].key in ["OUTPUT", "SCAT"] + and self.problem.data_files.output_only + ): filename = self.files["source_file"].name if filename.endswith(".zip") or filename.endswith(".sb3"): self.source_file_name = ( diff --git a/judge/views/problem.py b/judge/views/problem.py index 132b2d2..cd461ea 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -1044,6 +1044,7 @@ def problem_submit(request, problem, submission=None): judge_choices=judge_choices, instance=Submission(user=profile, problem=problem), request=request, + problem=problem, ) if form.is_valid(): if (