Add view to display rejudge success

This commit is contained in:
Quantum 2019-05-04 19:04:30 -07:00 committed by Guanzhong Chen
parent 24b59830a6
commit 9ba710b55c
7 changed files with 75 additions and 14 deletions

View File

@ -203,6 +203,7 @@ TEMPLATES = [
'django.template.context_processors.tz',
'django.template.context_processors.i18n',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
'judge.template_context.comet_location',
'judge.template_context.get_resource',
'judge.template_context.general_info',

View File

@ -128,8 +128,10 @@ urlpatterns = [
url(r'^/manage/submission', include([
url('^$', problem_manage.ManageProblemSubmissionView.as_view(), name='problem_manage_submissions'),
url('^/rejudge_all$', problem_manage.RejudgeAllSubmissionsView.as_view(),
url('^/rejudge/all$', problem_manage.RejudgeAllSubmissionsView.as_view(),
name='problem_submissions_rejudge_all'),
url('^/rejudge/success/(?P<task_id>[A-Za-z0-9-]*)$', problem_manage.rejudge_success,
name='problem_submissions_rejudge_success'),
])),
])),

View File

@ -1,8 +1,10 @@
from django.http import Http404
from celery.result import AsyncResult
from django.contrib import messages
from django.http import Http404, HttpResponseRedirect
from django.urls import reverse
from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from django.utils.translation import gettext as _, ngettext
from django.views.generic import DetailView
from django.views.generic.detail import BaseDetailView
@ -57,4 +59,16 @@ class ManageProblemSubmissionView(TitleMixin, ManageProblemSubmissionMixin, Deta
class RejudgeAllSubmissionsView(ManageProblemSubmissionActionMixin, BaseDetailView):
def perform_action(self):
status = rejudge_problem_all.delay(self.object.id)
return redirect_to_task_status(status, _('Rejudging all submissions for %s...') % (self.object.name,))
return redirect_to_task_status(
status, message=_('Rejudging all submissions for %s...') % (self.object.name,),
redirect=reverse('problem_submissions_rejudge_success', args=[self.object.code, status.id])
)
def rejudge_success(request, problem, task_id):
count = AsyncResult(task_id).result
if not isinstance(count, int):
raise Http404()
messages.success(request, ngettext('Successfully scheduled %d submission for rejudging.',
'Successfully scheduled %d submissions for rejudging.', count) % (count,))
return HttpResponseRedirect(reverse('problem_manage_submissions', args=[problem]))

View File

@ -363,7 +363,7 @@ ul.pagination {
line-height: 1;
color: #000;
text-shadow: 0 1px 0 #fff;
filter: alpha(opacity = 20);
filter: alpha(opacity=20);
opacity: 0.2;
}
@ -382,7 +382,7 @@ a.close {
color: #000;
text-decoration: none;
cursor: pointer;
filter: alpha(opacity = 50);
filter: alpha(opacity=50);
opacity: 0.5;
}
}
@ -472,3 +472,45 @@ ul.select2-selection__rendered {
.semibold {
font-weight: 600;
}
.messages {
list-style-type: none;
padding: 0;
li {
padding: 1em 1.5em;
margin-bottom: 1em;
border: 1px solid transparent;
border-radius: 5px;
&.debug {
color: #383d41;
background-color: #e2e3e5;
border-color: #d6d8db;
}
&.info {
color: #0c5460;
background-color: #d1ecf1;
border-color: #bee5eb;
}
&.success {
color: #155724;
background-color: #d4edda;
border-color: #c3e6cb;
}
&.warning {
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
&.error {
color: #721c24;
background-color: #f8d7da;
border-color: #f5c6cb;
}
}
}

7
templates/messages.html Normal file
View File

@ -0,0 +1,7 @@
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li class="{{ message.tags }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

View File

@ -1,13 +1,6 @@
{% extends "base.html" %}
{% block body %}
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li class="{{ message.tags }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% include "messages.html" %}
{% include "organization/requests/tabs.html" %}
{% if formset.forms %}

View File

@ -57,6 +57,8 @@
{% endblock %}
{% block body %}
{% include "messages.html" %}
<div class="panes">
<div class="pane">
<h3>{{ _('Rejudge Everything') }}</h3>