From cf431b8fab6e211f7126ccb8cb727a01d74e17cb Mon Sep 17 00:00:00 2001 From: Bui Tuan Dung Date: Mon, 19 Dec 2022 07:22:08 +0700 Subject: [PATCH] add resolver link --- dmoj/urls.py | 2 +- judge/views/resolver.py | 19 +++++++++++-------- templates/contest/contest-tabs.html | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dmoj/urls.py b/dmoj/urls.py index c9b4b58..61cd8f3 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -1099,7 +1099,7 @@ urlpatterns = [ ] ), ), - url(r"^resolver/", resolver.resolver, name="resolver"), + url(r"^resolver/(?P\w+)",resolver.resolver, name="resolver") ] + url_static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # if hasattr(settings, "INTERNAL_IPS"): diff --git a/judge/views/resolver.py b/judge/views/resolver.py index f31dcb7..65dad23 100644 --- a/judge/views/resolver.py +++ b/judge/views/resolver.py @@ -1,12 +1,15 @@ from django.shortcuts import render from django.utils.translation import gettext as _ - +from django.http import HttpResponseForbidden def resolver(request): - return render( - request, - "resolver/resolver.html", - { - "title": _("Resolver"), - }, - ) \ No newline at end of file + if request.user.is_superuser: + return render( + request, + "resolver/resolver.html", + { + "title": _("Resolver"), + }, + ) + return HttpResponseForbidden() + \ No newline at end of file diff --git a/templates/contest/contest-tabs.html b/templates/contest/contest-tabs.html index c601e93..993e0dd 100644 --- a/templates/contest/contest-tabs.html +++ b/templates/contest/contest-tabs.html @@ -22,6 +22,9 @@ {{ make_tab_item('ranking', 'fa fa-bar-chart', None, _('Hidden Rankings')) }} {% endif %} {% endif %} + {% if request.user.is_superuser %} + {{ make_tab_item('resolver', 'fa fa-check', url('resolver', contest.key), _('Resolver')) }} + {% endif %} {% if can_edit %} {% if perms.judge.moss_contest and has_moss_api_key %} {{ make_tab_item('moss', 'fa fa-gavel', url('contest_moss', contest.key), _('MOSS')) }}