Fix organization submissions

This commit is contained in:
cuom1999 2023-07-06 22:37:43 +07:00
parent a02814621e
commit 1595063463
2 changed files with 8 additions and 7 deletions

View file

@ -441,7 +441,7 @@ class OrganizationSubmissions(
LoginRequiredMixin, MemberOrganizationMixin, SubmissionsListBase LoginRequiredMixin, MemberOrganizationMixin, SubmissionsListBase
): ):
template_name = "organization/submissions.html" template_name = "organization/submissions.html"
@cached_property @cached_property
def in_contest(self): def in_contest(self):
return False return False
@ -453,7 +453,7 @@ class OrganizationSubmissions(
def get_queryset(self): def get_queryset(self):
return ( return (
super() super()
._get_entire_queryset() .get_queryset()
.filter(contest_object__organizations=self.organization) .filter(contest_object__organizations=self.organization)
) )

View file

@ -322,6 +322,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
context_object_name = "submissions" context_object_name = "submissions"
first_page_href = None first_page_href = None
include_frozen = False include_frozen = False
organization = None
def get_result_data(self): def get_result_data(self):
result = self._get_result_data() result = self._get_result_data()
@ -348,7 +349,11 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
return self.request.profile.current_contest.contest return self.request.profile.current_contest.contest
def _get_entire_queryset(self): def _get_entire_queryset(self):
queryset = Submission.objects.all() organization = self.organization or self.request.organization
if organization:
queryset = Submission.objects.filter(contest_object__organizations=organization)
else:
queryset = Submission.objects.all()
use_straight_join(queryset) use_straight_join(queryset)
queryset = submission_related(queryset.order_by("-id")) queryset = submission_related(queryset.order_by("-id"))
if self.show_problem: if self.show_problem:
@ -412,10 +417,6 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
def get_queryset(self): def get_queryset(self):
queryset = self._get_entire_queryset() queryset = self._get_entire_queryset()
if not self.in_contest: if not self.in_contest:
if self.request.organization:
queryset = queryset.filter(
contest_object__organizations=self.request.organization
)
join_sql_subquery( join_sql_subquery(
queryset, queryset,
subquery=str( subquery=str(