Add contest field to manage submission page
This commit is contained in:
parent
038aa8674a
commit
e1054077fa
6 changed files with 96 additions and 70 deletions
|
@ -467,7 +467,7 @@ class Contest(models.Model, PageVotable, Bookmarkable):
|
|||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
return f"{self.name} ({self.key})"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("contest_view", args=(self.key,))
|
||||
|
|
|
@ -8,7 +8,7 @@ from judge.utils.celery import Progress
|
|||
__all__ = ("apply_submission_filter", "rejudge_problem_filter", "rescore_problem")
|
||||
|
||||
|
||||
def apply_submission_filter(queryset, id_range, languages, results, contest):
|
||||
def apply_submission_filter(queryset, id_range, languages, results, contests):
|
||||
if id_range:
|
||||
start, end = id_range
|
||||
queryset = queryset.filter(id__gte=start, id__lte=end)
|
||||
|
@ -16,8 +16,8 @@ def apply_submission_filter(queryset, id_range, languages, results, contest):
|
|||
queryset = queryset.filter(language_id__in=languages)
|
||||
if results:
|
||||
queryset = queryset.filter(result__in=results)
|
||||
if contest:
|
||||
queryset = queryset.filter(contest_object=contest)
|
||||
if contests:
|
||||
queryset = queryset.filter(contest_object__in=contests)
|
||||
queryset = queryset.exclude(status__in=Submission.IN_PROGRESS_GRADING_STATUS)
|
||||
return queryset
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ class ManageProblemSubmissionView(TitleMixin, ManageProblemSubmissionMixin, Deta
|
|||
)
|
||||
]
|
||||
context["results"] = sorted(map(itemgetter(0), Submission.RESULT))
|
||||
context["in_contest"] = False
|
||||
context["current_contest"] = None
|
||||
if (
|
||||
self.request.in_contest_mode
|
||||
and self.object in self.request.participation.contest.problems.all()
|
||||
):
|
||||
context["in_contest"] = True
|
||||
context["current_contest"] = self.request.participation.contest
|
||||
|
||||
return context
|
||||
|
||||
|
@ -106,20 +106,12 @@ class BaseActionSubmissionsView(
|
|||
|
||||
try:
|
||||
languages = list(map(int, self.request.POST.getlist("language")))
|
||||
results = list(map(int, self.request.POST.getlist("result")))
|
||||
contests = list(map(int, self.request.POST.getlist("contest")))
|
||||
except ValueError:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
contest = None
|
||||
try:
|
||||
in_contest = bool(self.request.POST.get("in_contest", False))
|
||||
if in_contest:
|
||||
contest = self.request.participation.contest
|
||||
except (KeyError, ValueError):
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
return self.generate_response(
|
||||
id_range, languages, self.request.POST.getlist("result"), contest
|
||||
)
|
||||
return self.generate_response(id_range, languages, results, contests)
|
||||
|
||||
def generate_response(self, id_range, languages, results, contest):
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -85,10 +85,17 @@ class ProblemSelect2View(Select2View):
|
|||
|
||||
|
||||
class ContestSelect2View(Select2View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.problem_id = kwargs.get("problem_id", request.GET.get("problem_id", ""))
|
||||
return super(ContestSelect2View, self).get(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return Contest.get_visible_contests(self.request.user).filter(
|
||||
q = Contest.get_visible_contests(self.request.user).filter(
|
||||
Q(key__icontains=self.term) | Q(name__icontains=self.term)
|
||||
)
|
||||
if self.problem_id:
|
||||
q = q.filter(problems=self.problem_id)
|
||||
return q
|
||||
|
||||
|
||||
class CommentSelect2View(Select2View):
|
||||
|
|
|
@ -2,7 +2,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: lqdoj2\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-11-28 08:35+0700\n"
|
||||
"POT-Creation-Date: 2023-11-29 08:53+0700\n"
|
||||
"PO-Revision-Date: 2021-07-20 03:44\n"
|
||||
"Last-Translator: Icyene\n"
|
||||
"Language-Team: Vietnamese\n"
|
||||
|
@ -46,7 +46,7 @@ msgstr ""
|
|||
msgid "Recent"
|
||||
msgstr "Gần đây"
|
||||
|
||||
#: chat_box/views.py:420 templates/base.html:187
|
||||
#: chat_box/views.py:420 templates/base.html:189
|
||||
#: templates/comments/content-list.html:78
|
||||
#: templates/contest/contest-list-tabs.html:4
|
||||
#: templates/contest/ranking-table.html:47
|
||||
|
@ -196,7 +196,7 @@ msgstr "Tính toán lại kết quả"
|
|||
msgid "username"
|
||||
msgstr "tên đăng nhập"
|
||||
|
||||
#: judge/admin/contest.py:504 templates/base.html:239
|
||||
#: judge/admin/contest.py:504 templates/base.html:241
|
||||
msgid "virtual"
|
||||
msgstr "ảo"
|
||||
|
||||
|
@ -409,7 +409,7 @@ msgstr "Bạn không có quyền chấm lại nhiều bài nộp như vậy."
|
|||
msgid "Rejudge the selected submissions"
|
||||
msgstr "Chấm lại các bài nộp đã chọn"
|
||||
|
||||
#: judge/admin/submission.py:302 judge/views/problem_manage.py:226
|
||||
#: judge/admin/submission.py:302 judge/views/problem_manage.py:228
|
||||
#, python-format
|
||||
msgid "%d submission were successfully rescored."
|
||||
msgid_plural "%d submissions were successfully rescored."
|
||||
|
@ -531,55 +531,55 @@ msgstr "Thành viên mới"
|
|||
msgid "These usernames don't exist: {usernames}"
|
||||
msgstr "Các tên đăng nhập này không tồn tại: {usernames}"
|
||||
|
||||
#: judge/forms.py:421
|
||||
#: judge/forms.py:422
|
||||
msgid "Username/Email"
|
||||
msgstr "Tên đăng nhập / Email"
|
||||
|
||||
#: judge/forms.py:422 judge/views/email.py:22
|
||||
#: judge/forms.py:424 judge/views/email.py:22
|
||||
#: templates/registration/registration_form.html:46
|
||||
#: templates/registration/registration_form.html:60
|
||||
#: templates/user/edit-profile.html:108 templates/user/import/table_csv.html:5
|
||||
msgid "Password"
|
||||
msgstr "Mật khẩu"
|
||||
|
||||
#: judge/forms.py:448
|
||||
#: judge/forms.py:450
|
||||
msgid "Two Factor Authentication tokens must be 6 decimal digits."
|
||||
msgstr "Two Factor Authentication phải chứa 6 chữ số."
|
||||
|
||||
#: judge/forms.py:461 templates/registration/totp_auth.html:32
|
||||
#: judge/forms.py:463 templates/registration/totp_auth.html:32
|
||||
msgid "Invalid Two Factor Authentication token."
|
||||
msgstr "Token Two Factor Authentication không hợp lệ."
|
||||
|
||||
#: judge/forms.py:468 judge/models/problem.py:130
|
||||
#: judge/forms.py:470 judge/models/problem.py:130
|
||||
msgid "Problem code must be ^[a-z0-9]+$"
|
||||
msgstr "Mã bài phải có dạng ^[a-z0-9]+$"
|
||||
|
||||
#: judge/forms.py:475
|
||||
#: judge/forms.py:477
|
||||
msgid "Problem with code already exists."
|
||||
msgstr "Mã bài đã tồn tại."
|
||||
|
||||
#: judge/forms.py:482 judge/models/contest.py:95
|
||||
#: judge/forms.py:484 judge/models/contest.py:95
|
||||
msgid "Contest id must be ^[a-z0-9]+$"
|
||||
msgstr "Mã kỳ thi phải có dạng ^[a-z0-9]+$"
|
||||
|
||||
#: judge/forms.py:489 templates/contest/clone.html:47
|
||||
#: judge/forms.py:491 templates/contest/clone.html:47
|
||||
#: templates/problem/search-form.html:39
|
||||
msgid "Group"
|
||||
msgstr "Nhóm"
|
||||
|
||||
#: judge/forms.py:497
|
||||
#: judge/forms.py:499
|
||||
msgid "Contest with key already exists."
|
||||
msgstr "Mã kỳ thi đã tồn tại."
|
||||
|
||||
#: judge/forms.py:505
|
||||
#: judge/forms.py:507
|
||||
msgid "Group doesn't exist."
|
||||
msgstr "Nhóm không tồn tại."
|
||||
|
||||
#: judge/forms.py:507
|
||||
#: judge/forms.py:509
|
||||
msgid "You don't have permission in this group."
|
||||
msgstr "Bạn không có quyền trong nhóm này."
|
||||
|
||||
#: judge/forms.py:557
|
||||
#: judge/forms.py:559
|
||||
msgid "This problem is duplicated."
|
||||
msgstr "Bài này bị lặp"
|
||||
|
||||
|
@ -3302,17 +3302,17 @@ msgstr "File init.yml cho %s"
|
|||
msgid "Managing submissions for %s"
|
||||
msgstr "Quản lý bài nộp cho %s"
|
||||
|
||||
#: judge/views/problem_manage.py:135
|
||||
#: judge/views/problem_manage.py:137
|
||||
#, python-format
|
||||
msgid "Rejudging selected submissions for %s..."
|
||||
msgstr "Đang chấm lại các bài nộp cho %s..."
|
||||
|
||||
#: judge/views/problem_manage.py:195
|
||||
#: judge/views/problem_manage.py:197
|
||||
#, python-format
|
||||
msgid "Rescoring all submissions for %s..."
|
||||
msgstr "Đang tính điểm lại các bài nộp cho %s..."
|
||||
|
||||
#: judge/views/problem_manage.py:210
|
||||
#: judge/views/problem_manage.py:212
|
||||
#, python-format
|
||||
msgid "Successfully scheduled %d submission for rejudging."
|
||||
msgid_plural "Successfully scheduled %d submissions for rejudging."
|
||||
|
@ -3568,7 +3568,7 @@ msgid "Updated on site"
|
|||
msgstr "Được cập nhật trên web"
|
||||
|
||||
#: judge/views/user.py:431 templates/admin/auth/user/change_form.html:14
|
||||
#: templates/admin/auth/user/change_form.html:17 templates/base.html:199
|
||||
#: templates/admin/auth/user/change_form.html:17 templates/base.html:201
|
||||
#: templates/user/user-tabs.html:11
|
||||
msgid "Edit profile"
|
||||
msgstr "Chỉnh sửa thông tin"
|
||||
|
@ -3671,48 +3671,48 @@ msgstr "Chat"
|
|||
msgid "Notification"
|
||||
msgstr "Thông báo"
|
||||
|
||||
#: templates/base.html:173
|
||||
#: templates/base.html:174
|
||||
msgid "Dark Mode"
|
||||
msgstr ""
|
||||
|
||||
#: templates/base.html:183
|
||||
#: templates/base.html:185
|
||||
msgid "Profile"
|
||||
msgstr "Trang cá nhân"
|
||||
|
||||
#: templates/base.html:192
|
||||
#: templates/base.html:194
|
||||
msgid "Internal"
|
||||
msgstr "Nội bộ"
|
||||
|
||||
#: templates/base.html:195
|
||||
#: templates/base.html:197
|
||||
msgid "Stats"
|
||||
msgstr "Thống kê"
|
||||
|
||||
#: templates/base.html:208
|
||||
#: templates/base.html:210
|
||||
msgid "Log out"
|
||||
msgstr "Đăng xuất"
|
||||
|
||||
#: templates/base.html:218
|
||||
#: templates/base.html:220
|
||||
#: templates/registration/password_reset_complete.html:4
|
||||
msgid "Log in"
|
||||
msgstr "Đăng nhập"
|
||||
|
||||
#: templates/base.html:219
|
||||
#: templates/base.html:221
|
||||
msgid "Sign up"
|
||||
msgstr "Đăng ký"
|
||||
|
||||
#: templates/base.html:233
|
||||
#: templates/base.html:235
|
||||
msgid "spectating"
|
||||
msgstr "đang theo dõi"
|
||||
|
||||
#: templates/base.html:245
|
||||
#: templates/base.html:247
|
||||
msgid "Compete"
|
||||
msgstr "Thi"
|
||||
|
||||
#: templates/base.html:247
|
||||
#: templates/base.html:249
|
||||
msgid "General"
|
||||
msgstr "Chung"
|
||||
|
||||
#: templates/base.html:254
|
||||
#: templates/base.html:256
|
||||
msgid "This site works best with JavaScript enabled."
|
||||
msgstr ""
|
||||
|
||||
|
@ -4823,79 +4823,87 @@ msgstr "Để trống nếu không lọc theo ngôn ngữ"
|
|||
msgid "Leave empty to not filter by result"
|
||||
msgstr "Để trống nếu không lọc theo kết quả"
|
||||
|
||||
#: templates/problem/manage_submission.html:79
|
||||
#: templates/problem/manage_submission.html:64
|
||||
msgid "Leave empty to not filter by contest"
|
||||
msgstr "Để trống nếu không lọc theo kỳ thi"
|
||||
|
||||
#: templates/problem/manage_submission.html:94
|
||||
msgid "Need valid values for both start and end IDs."
|
||||
msgstr "Cần số liệu hợp lệ cho ID bắt đầu và kết thúc."
|
||||
|
||||
#: templates/problem/manage_submission.html:82
|
||||
#: templates/problem/manage_submission.html:97
|
||||
msgid "End ID must be after start ID."
|
||||
msgstr "ID kết thúc phải lớn hơn hoặc bằng ID khởi đầu."
|
||||
|
||||
#: templates/problem/manage_submission.html:95
|
||||
#: templates/problem/manage_submission.html:110
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"You are about to {action} {count} submissions. Are you sure you want to do "
|
||||
"this?"
|
||||
msgstr "Bạn chuẩn bị {action} {count} bài nộp. Tiếp tục?"
|
||||
|
||||
#: templates/problem/manage_submission.html:102
|
||||
#: templates/problem/manage_submission.html:117
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"You are about to {action} a few submissions. Are you sure you want to do "
|
||||
"this?"
|
||||
msgstr "Bạn chuẩn bị {action} vài bài nộp. Tiếp tục?"
|
||||
|
||||
#: templates/problem/manage_submission.html:126
|
||||
#: templates/problem/manage_submission.html:141
|
||||
#: templates/submission/list.html:337
|
||||
msgid "Filter submissions"
|
||||
msgstr "Lọc bài nộp"
|
||||
|
||||
#: templates/problem/manage_submission.html:131
|
||||
#: templates/problem/manage_submission.html:146
|
||||
msgid "Filter by ID:"
|
||||
msgstr "Lọc theo ID:"
|
||||
|
||||
#: templates/problem/manage_submission.html:134
|
||||
#: templates/problem/manage_submission.html:149
|
||||
msgid "Starting ID:"
|
||||
msgstr "ID bắt đầu:"
|
||||
|
||||
#: templates/problem/manage_submission.html:138
|
||||
#: templates/problem/manage_submission.html:153
|
||||
msgid "Ending ID:"
|
||||
msgstr "ID kết thúc:"
|
||||
|
||||
#: templates/problem/manage_submission.html:142
|
||||
#: templates/problem/manage_submission.html:157
|
||||
msgid "This range includes both endpoints."
|
||||
msgstr "Bao gồm hai đầu mút."
|
||||
|
||||
#: templates/problem/manage_submission.html:145
|
||||
#: templates/problem/manage_submission.html:160
|
||||
msgid "Filter by language:"
|
||||
msgstr "Lọc theo ngôn ngữ:"
|
||||
|
||||
#: templates/problem/manage_submission.html:153
|
||||
#: templates/problem/manage_submission.html:168
|
||||
msgid "Filter by result:"
|
||||
msgstr "Lọc theo kết quả:"
|
||||
|
||||
#: templates/problem/manage_submission.html:161
|
||||
#: templates/problem/manage_submission.html:176
|
||||
msgid "In current contest"
|
||||
msgstr "Trong kỳ thi hiện tại"
|
||||
|
||||
#: templates/problem/manage_submission.html:167
|
||||
#: templates/problem/manage_submission.html:180
|
||||
msgid "Filter by contest:"
|
||||
msgstr "Lọc theo kỳ thi:"
|
||||
|
||||
#: templates/problem/manage_submission.html:188
|
||||
msgid "Action"
|
||||
msgstr "Hành động"
|
||||
|
||||
#: templates/problem/manage_submission.html:169
|
||||
#: templates/problem/manage_submission.html:190
|
||||
msgid "Rejudge selected submissions"
|
||||
msgstr "Chấm lại những bài nộp này"
|
||||
|
||||
#: templates/problem/manage_submission.html:174
|
||||
#: templates/problem/manage_submission.html:195
|
||||
msgid "Download selected submissions"
|
||||
msgstr "Tải các bài nộp này"
|
||||
|
||||
#: templates/problem/manage_submission.html:180
|
||||
#: templates/problem/manage_submission.html:201
|
||||
#, python-format
|
||||
msgid "Are you sure you want to rescore %(count)d submissions?"
|
||||
msgstr "Bạn có chắc muốn tính điểm lại %(count)d bài nộp?"
|
||||
|
||||
#: templates/problem/manage_submission.html:181
|
||||
#: templates/problem/manage_submission.html:202
|
||||
msgid "Rescore all submissions"
|
||||
msgstr "Tính điểm lại các bài nộp"
|
||||
|
||||
|
|
|
@ -59,6 +59,21 @@
|
|||
placeholder: '{{ _('Leave empty to not filter by result') }}'
|
||||
});
|
||||
|
||||
$('#by-contest-filter').select2({
|
||||
multiple: true,
|
||||
placeholder: '{{ _('Leave empty to not filter by contest') }}',
|
||||
ajax: {
|
||||
url: "{{url('contest_select2')}}",
|
||||
data: function(params) {
|
||||
return {
|
||||
term: params.term,
|
||||
problem_id: {{problem.id}}
|
||||
};
|
||||
},
|
||||
delay: 250,
|
||||
}
|
||||
});
|
||||
|
||||
$('#rescore-all').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (confirm(this.dataset.warning)) {
|
||||
|
@ -157,10 +172,14 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% if in_contest %}
|
||||
<label for="in-contest" name="in_contest">{{ _('In current contest') }}:</label>
|
||||
<input type="checkbox" name="in_contest">
|
||||
{% endif %}
|
||||
<div class="control-group">
|
||||
<label for="by-contest-filter">{{ _('Filter by contest:') }}</label>
|
||||
<select id="by-contest-filter" name="contest" multiple>
|
||||
{% if current_contest %}
|
||||
<option selected value="{{current_contest.id}}">{{ current_contest }}</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="pane">
|
||||
|
|
Loading…
Reference in a new issue