fix test_formatter
This commit is contained in:
parent
14ecef649e
commit
c818001b5c
14 changed files with 961 additions and 0 deletions
26
judge/models/test_formatter.py
Normal file
26
judge/models/test_formatter.py
Normal 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,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue