New UI for users and submissions

This commit is contained in:
cuom1999 2022-06-06 11:36:35 -05:00
parent d0ac92914d
commit 247e0e4740
12 changed files with 183 additions and 226 deletions

View file

@ -286,7 +286,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
show_problem = True
title = gettext_lazy("All submissions")
content_title = gettext_lazy("All submissions")
tab = "all_submissions_list"
page_type = "all_submissions_list"
template_name = "submission/list.html"
context_object_name = "submissions"
first_page_href = None
@ -429,7 +429,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
context["first_page_href"] = (self.first_page_href or ".") + suffix
context["my_submissions_link"] = self.get_my_submissions_page()
context["all_submissions_link"] = self.get_all_submissions_page()
context["tab"] = self.tab
context["page_type"] = self.page_type
return context
@ -460,9 +460,9 @@ class ConditionalUserTabMixin(object):
def get_context_data(self, **kwargs):
context = super(ConditionalUserTabMixin, self).get_context_data(**kwargs)
if self.request.user.is_authenticated and self.request.profile == self.profile:
context["tab"] = "my_submissions_tab"
context["page_type"] = "my_submissions_tab"
else:
context["tab"] = "user_submissions_tab"
context["page_type"] = "user_submissions_tab"
context["tab_username"] = self.profile.user.username
return context

View file

@ -461,6 +461,7 @@ class UserList(QueryStringSortMixin, DiggPaginatorMixin, TitleMixin, ListView):
all_sorts = frozenset(("points", "problem_count", "rating", "performance_points"))
default_desc = all_sorts
default_sort = "-performance_points"
filter_friend = False
def filter_friend_queryset(self, queryset):
friends = list(self.request.profile.get_friends())
@ -484,6 +485,7 @@ class UserList(QueryStringSortMixin, DiggPaginatorMixin, TitleMixin, ListView):
if (self.request.GET.get("friend") == "true") and self.request.profile:
ret = self.filter_friend_queryset(ret)
self.filter_friend = True
return ret
def get_context_data(self, **kwargs):
@ -492,6 +494,7 @@ class UserList(QueryStringSortMixin, DiggPaginatorMixin, TitleMixin, ListView):
context["users"], rank=self.paginate_by * (context["page_obj"].number - 1)
)
context["first_page_href"] = "."
context["page_type"] = "friends" if self.filter_friend else "list"
context.update(self.get_sort_context())
context.update(self.get_sort_paginate_context())
return context