add bookmarks page

This commit is contained in:
Zhao-Linux 2022-11-18 04:21:32 +07:00
parent 8108967959
commit 6e72c08ef4
9 changed files with 143 additions and 9 deletions

View file

@ -13,6 +13,7 @@ from django.db import transaction
from django.db.models import Count, Max, Min
from django.db.models.fields import DateField
from django.db.models.functions import Cast, ExtractYear
from judge.models.bookmark import MakeBookMark
from django.forms import Form
from django.http import (
Http404,
@ -52,7 +53,7 @@ from judge.utils.views import (
)
from .contests import ContestRanking
__all__ = ["UserPage", "UserAboutPage", "UserProblemsPage", "users", "edit_profile"]
__all__ = ["UserPage", "UserAboutPage", "UserProblemsPage", "UserBookMarkPage", "users", "edit_profile"]
def remap_keys(iterable, mapping):
@ -349,6 +350,27 @@ class UserProblemsPage(UserPage):
return context
class UserBookMarkPage(UserPage):
template_name = "user/user-bookmarks.html"
def get_context_data(self, **kwargs):
context = super(UserBookMarkPage, self).get_context_data(**kwargs)
makedownlist = MakeBookMark.objects.filter(user=self.object)
pagelist = makedownlist.filter(bookmark__page__startswith='b')
problemlist = makedownlist.filter(bookmark__page__startswith='p')
contestlist = makedownlist.filter(bookmark__page__startswith='c')
context["pagelist"] = makedownlist
context["postlist"] = pagelist
context["problemlist"] = problemlist
context["contestlist"] = contestlist
context["haspost"] = pagelist.exists()
context["hasproblem"] = problemlist.exists()
context["hascontest"] = contestlist.exists()
return context
class UserPerformancePointsAjax(UserProblemsPage):
template_name = "user/pp-table-body.html"