diff --git a/dmoj/urls.py b/dmoj/urls.py index 61cd8f3..d2c2c12 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -1099,7 +1099,7 @@ urlpatterns = [ ] ), ), - url(r"^resolver/(?P\w+)",resolver.resolver, name="resolver") + url(r"^resolver/(?P\w+)",resolver.Resolver.as_view(), 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 65dad23..cdbe4af 100644 --- a/judge/views/resolver.py +++ b/judge/views/resolver.py @@ -1,15 +1,19 @@ -from django.shortcuts import render +from django.views.generic import TemplateView from django.utils.translation import gettext as _ from django.http import HttpResponseForbidden -def resolver(request): - if request.user.is_superuser: - return render( - request, - "resolver/resolver.html", - { - "title": _("Resolver"), - }, - ) - return HttpResponseForbidden() +class Resolver(TemplateView): + title = _("Resolver") + template_name = "resolver/resolver.html" + + def get_context_data(self, **kwargs): + context = super(Resolver, self).get_context_data(**kwargs) + context["contest_json"] = "/static/contest.json" + return context + + def get(self, request, *args, **kwargs): + if request.user.is_superuser: + return super(Resolver, self).get(request, *args, **kwargs) + return HttpResponseForbidden() + \ No newline at end of file diff --git a/templates/resolver/media-js.html b/templates/resolver/media-js.html index 8de1eb8..d6fce6a 100644 --- a/templates/resolver/media-js.html +++ b/templates/resolver/media-js.html @@ -7,7 +7,7 @@ var speed = 700; var autopress = false; $(document).ready(function() { - $.getJSON('{{ static('contest.json') }}', function (data) { + $.getJSON('{{ contest_json }}', function (data) { console.log("OK"); var resolver = new Resolver(data.problem_sub, data.sub_frozen, data.problems, data.users); window.resolver = resolver;