2020-01-21 06:35:58 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from judge.models import Problem, ProblemGroup, ProblemType
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2022-05-14 17:57:27 +00:00
|
|
|
help = "create an empty problem"
|
2020-01-21 06:35:58 +00:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
2022-05-14 17:57:27 +00:00
|
|
|
parser.add_argument("code", help="problem code")
|
|
|
|
parser.add_argument("name", help="problem title")
|
|
|
|
parser.add_argument("body", help="problem description")
|
|
|
|
parser.add_argument("type", help="problem type")
|
|
|
|
parser.add_argument("group", help="problem group")
|
2020-01-21 06:35:58 +00:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
problem = Problem()
|
2022-05-14 17:57:27 +00:00
|
|
|
problem.code = options["code"]
|
|
|
|
problem.name = options["name"]
|
|
|
|
problem.description = options["body"]
|
|
|
|
problem.group = ProblemGroup.objects.get(name=options["group"])
|
|
|
|
problem.types = [ProblemType.objects.get(name=options["type"])]
|
2020-01-21 06:35:58 +00:00
|
|
|
problem.save()
|