diff --git a/dmoj/urls.py b/dmoj/urls.py index f696a1e..e184e0d 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -589,19 +589,29 @@ urlpatterns = [ name="organization_home", ), url( - r"^/users$", - organization.OrganizationUsers.as_view(), - name="organization_users", + r"^/users/", + paged_list_view( + organization.OrganizationUsers, + "organization_users", + ), ), url( - r"^/problems$", - organization.OrganizationProblems.as_view(), - name="organization_problems", + r"^/problems/", + paged_list_view( + organization.OrganizationProblems, "organization_problems" + ), ), url( - r"^/contests$", - organization.OrganizationContests.as_view(), - name="organization_contests", + r"^/contests/", + paged_list_view( + organization.OrganizationContests, "organization_contests" + ), + ), + url( + r"^/submissions/", + paged_list_view( + organization.OrganizationSubmissions, "organization_submissions" + ), ), url( r"^/join$", diff --git a/judge/models/profile.py b/judge/models/profile.py index fe8ce17..2a0a80f 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -112,6 +112,9 @@ class Organization(models.Model): def get_contests_url(self): return reverse("organization_contests", args=(self.id, self.slug)) + def get_submissions_url(self): + return reverse("organization_submissions", args=(self.id, self.slug)) + class Meta: ordering = ["name"] permissions = ( diff --git a/judge/views/organization.py b/judge/views/organization.py index 2288d96..93b6e74 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -18,6 +18,7 @@ from django.http import ( from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils import timezone +from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.translation import gettext as _, gettext_lazy, ungettext from django.views.generic import ( @@ -50,6 +51,7 @@ from judge.models import ( Profile, Contest, ) +from judge import event_poster as event from judge.utils.ranker import ranker from judge.utils.views import ( TitleMixin, @@ -60,6 +62,7 @@ from judge.utils.views import ( from judge.utils.problems import user_attempted_ids from judge.views.problem import ProblemList from judge.views.contests import ContestList +from judge.views.submission import AllSubmissions, SubmissionsListBase __all__ = [ "OrganizationList", @@ -364,6 +367,41 @@ class OrganizationContests(LoginRequiredMixin, MemberOrganizationMixin, ContestL return context +class OrganizationSubmissions( + LoginRequiredMixin, MemberOrganizationMixin, SubmissionsListBase +): + template_name = "organization/submissions.html" + + @cached_property + def in_contest(self): + return False + + @cached_property + def contest(self): + return None + + def get_queryset(self): + return ( + super() + ._get_queryset() + .filter(contest_object__organizations=self.organization) + ) + + def get_context_data(self, **kwargs): + context = super(OrganizationSubmissions, self).get_context_data(**kwargs) + context["dynamic_update"] = context["page_obj"].number == 1 + context["last_msg"] = event.last() + context["stats_update_interval"] = 3600 + context["page_type"] = "submissions" + context["page_prefix"] = None + context["page_suffix"] = suffix = ( + ("?" + self.request.GET.urlencode()) if self.request.GET else "" + ) + context["first_page_href"] = (self.first_page_href or ".") + suffix + + return context + + class OrganizationMembershipChange( LoginRequiredMixin, OrganizationMixin, SingleObjectMixin, View ): diff --git a/templates/organization/org-left-sidebar.html b/templates/organization/org-left-sidebar.html index 7f953c3..8f2c442 100644 --- a/templates/organization/org-left-sidebar.html +++ b/templates/organization/org-left-sidebar.html @@ -3,6 +3,7 @@ {% if is_member or can_edit %} {{ make_tab_item('problems', 'fa fa-list', organization.get_problems_url(), _('Problems')) }} {{ make_tab_item('contests', 'fa fa-trophy', organization.get_contests_url(), _('Contests')) }} + {{ make_tab_item('submissions', 'fa fa-book', organization.get_submissions_url(), _('Submissions')) }} {% endif %} {{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }} {% if perms.judge.change_organization %} diff --git a/templates/organization/submissions.html b/templates/organization/submissions.html new file mode 100644 index 0000000..5090f7d --- /dev/null +++ b/templates/organization/submissions.html @@ -0,0 +1,4 @@ +{% extends "submission/list.html" %} +{% block left_sidebar %} + {% include "organization/org-left-sidebar.html" %} +{% endblock %} \ No newline at end of file