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", name="organization_home",
), ),
url( url(
r"^/users$", r"^/users/",
organization.OrganizationUsers.as_view(), paged_list_view(
name="organization_users", organization.OrganizationUsers,
"organization_users",
),
), ),
url( url(
r"^/problems$", r"^/problems/",
organization.OrganizationProblems.as_view(), paged_list_view(
name="organization_problems", organization.OrganizationProblems, "organization_problems"
),
), ),
url( url(
r"^/contests$", r"^/contests/",
organization.OrganizationContests.as_view(), paged_list_view(
name="organization_contests", organization.OrganizationContests, "organization_contests"
),
),
url(
r"^/submissions/",
paged_list_view(
organization.OrganizationSubmissions, "organization_submissions"
),
), ),
url( url(
r"^/join$", r"^/join$",

View file

@ -112,6 +112,9 @@ class Organization(models.Model):
def get_contests_url(self): def get_contests_url(self):
return reverse("organization_contests", args=(self.id, self.slug)) 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: class Meta:
ordering = ["name"] ordering = ["name"]
permissions = ( permissions = (

View file

@ -18,6 +18,7 @@ from django.http import (
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.urls import reverse from django.urls import reverse
from django.utils import timezone from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _, gettext_lazy, ungettext from django.utils.translation import gettext as _, gettext_lazy, ungettext
from django.views.generic import ( from django.views.generic import (
@ -50,6 +51,7 @@ from judge.models import (
Profile, Profile,
Contest, Contest,
) )
from judge import event_poster as event
from judge.utils.ranker import ranker from judge.utils.ranker import ranker
from judge.utils.views import ( from judge.utils.views import (
TitleMixin, TitleMixin,
@ -60,6 +62,7 @@ from judge.utils.views import (
from judge.utils.problems import user_attempted_ids from judge.utils.problems import user_attempted_ids
from judge.views.problem import ProblemList from judge.views.problem import ProblemList
from judge.views.contests import ContestList from judge.views.contests import ContestList
from judge.views.submission import AllSubmissions, SubmissionsListBase
__all__ = [ __all__ = [
"OrganizationList", "OrganizationList",
@ -364,6 +367,41 @@ class OrganizationContests(LoginRequiredMixin, MemberOrganizationMixin, ContestL
return context 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( class OrganizationMembershipChange(
LoginRequiredMixin, OrganizationMixin, SingleObjectMixin, View LoginRequiredMixin, OrganizationMixin, SingleObjectMixin, View
): ):

View file

@ -3,6 +3,7 @@
{% if is_member or can_edit %} {% if is_member or can_edit %}
{{ make_tab_item('problems', 'fa fa-list', organization.get_problems_url(), _('Problems')) }} {{ 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('contests', 'fa fa-trophy', organization.get_contests_url(), _('Contests')) }}
{{ make_tab_item('submissions', 'fa fa-book', organization.get_submissions_url(), _('Submissions')) }}
{% endif %} {% endif %}
{{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }} {{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }}
{% if perms.judge.change_organization %} {% 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 %}