Test Formatter (#100)

This commit is contained in:
Bao Le 2024-01-09 02:27:20 +08:00 committed by GitHub
parent 14ecef649e
commit 04c6af1dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1624 additions and 0 deletions

View file

@ -53,12 +53,15 @@ from judge.models.submission import (
SubmissionSource,
SubmissionTestCase,
)
from judge.models.test_formatter import TestFormatterModel
from judge.models.ticket import Ticket, TicketMessage
from judge.models.volunteer import VolunteerProblemVote
from judge.models.pagevote import PageVote, PageVoteVoter
from judge.models.bookmark import BookMark, MakeBookMark
from judge.models.course import Course
from judge.models.notification import Notification, NotificationProfile
from judge.models.test_formatter import TestFormatterModel
revisions.register(Profile, exclude=["points", "last_access", "ip", "rating"])
revisions.register(Problem, follow=["language_limits"])

View file

@ -0,0 +1,26 @@
import os
from django.db import models
from dmoj import settings
from django.utils.translation import gettext_lazy as _
__all__ = [
"TestFormatterModel",
]
def test_formatter_path(test_formatter, filename):
tail = filename.split(".")[-1]
head = filename.split(".")[0]
if str(tail).lower() != "zip":
raise Exception("400: Only ZIP files are supported")
new_filename = f"{head}.{tail}"
return os.path.join(settings.DMOJ_TEST_FORMATTER_ROOT, new_filename)
class TestFormatterModel(models.Model):
file = models.FileField(
verbose_name=_("testcase file"),
null=True,
blank=True,
upload_to=test_formatter_path,
)