From 261841bab0dc0dc8888e5a58c925aa85b71650d0 Mon Sep 17 00:00:00 2001 From: Quang-Truong Nguyen Date: Sun, 14 Jan 2024 11:33:37 +0700 Subject: [PATCH] Preselect default categories when creating problems (#372) --- judge/views/problem.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/judge/views/problem.py b/judge/views/problem.py index de0a9c06e..dfed812a1 100755 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -822,6 +822,14 @@ def get_initial(self): initial['description'] = misc_config(self.request)['misc_config']['description_example'] initial['memory_limit'] = 262144 # 256 MB initial['partial'] = True + try: + initial['group'] = ProblemGroup.objects.get(name='Uncategorized').pk + except ProblemGroup.DoesNotExist: + initial['group'] = ProblemGroup.objects.order_by('id').first().pk + try: + initial['types'] = ProblemType.objects.get(name='uncategorized').pk + except ProblemType.DoesNotExist: + initial['types'] = ProblemType.objects.order_by('id').first().pk return initial