Add group submissions

This commit is contained in:
cuom1999 2022-06-08 05:11:30 +07:00
parent 247e0e4740
commit 1efbf4cc91
5 changed files with 65 additions and 9 deletions

View file

@ -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$",

View file

@ -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 = (

View file

@ -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
):

View file

@ -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 %}

View file

@ -0,0 +1,4 @@
{% extends "submission/list.html" %}
{% block left_sidebar %}
{% include "organization/org-left-sidebar.html" %}
{% endblock %}