Format and add trans
This commit is contained in:
parent
bba7a761ac
commit
2c39774ff7
10 changed files with 294 additions and 205 deletions
|
@ -41,7 +41,9 @@ def bookmark_page(request, delta):
|
|||
raise Http404()
|
||||
|
||||
if delta == 0:
|
||||
bookmarklist = MakeBookMark.objects.filter(bookmark=bookmark_page.first(), user=request.profile)
|
||||
bookmarklist = MakeBookMark.objects.filter(
|
||||
bookmark=bookmark_page.first(), user=request.profile
|
||||
)
|
||||
if not bookmarklist.exists():
|
||||
newbookmark = MakeBookMark(
|
||||
bookmark=bookmark_page.first(),
|
||||
|
@ -49,7 +51,9 @@ def bookmark_page(request, delta):
|
|||
)
|
||||
newbookmark.save()
|
||||
else:
|
||||
bookmarklist = MakeBookMark.objects.filter(bookmark=bookmark_page.first(), user=request.profile)
|
||||
bookmarklist = MakeBookMark.objects.filter(
|
||||
bookmark=bookmark_page.first(), user=request.profile
|
||||
)
|
||||
if bookmarklist.exists():
|
||||
bookmarklist.delete()
|
||||
|
||||
|
@ -79,4 +83,4 @@ class BookMarkListView(ListView):
|
|||
page=self.get_comment_page(item)
|
||||
)
|
||||
setattr(item, "bookmark", bookmark)
|
||||
return context
|
||||
return context
|
||||
|
|
|
@ -383,7 +383,13 @@ class ContestMixin(object):
|
|||
)
|
||||
|
||||
|
||||
class ContestDetail(ContestMixin, TitleMixin, CommentedDetailView, PageVoteDetailView, BookMarkDetailView):
|
||||
class ContestDetail(
|
||||
ContestMixin,
|
||||
TitleMixin,
|
||||
CommentedDetailView,
|
||||
PageVoteDetailView,
|
||||
BookMarkDetailView,
|
||||
):
|
||||
template_name = "contest/contest.html"
|
||||
|
||||
def get_comment_page(self):
|
||||
|
|
|
@ -245,7 +245,11 @@ class ProblemRaw(
|
|||
|
||||
|
||||
class ProblemDetail(
|
||||
ProblemMixin, SolvedProblemMixin, CommentedDetailView, PageVoteDetailView, BookMarkDetailView
|
||||
ProblemMixin,
|
||||
SolvedProblemMixin,
|
||||
CommentedDetailView,
|
||||
PageVoteDetailView,
|
||||
BookMarkDetailView,
|
||||
):
|
||||
context_object_name = "problem"
|
||||
template_name = "problem/problem.html"
|
||||
|
@ -948,6 +952,7 @@ class ProblemFeed(ProblemList, PageVoteListView, BookMarkListView):
|
|||
context["has_show_editorial_option"] = False
|
||||
context["has_have_editorial_option"] = False
|
||||
context = self.add_pagevote_context_data(context)
|
||||
context = self.add_bookmark_context_data(context)
|
||||
|
||||
return context
|
||||
|
||||
|
|
|
@ -53,7 +53,14 @@ from judge.utils.views import (
|
|||
)
|
||||
from .contests import ContestRanking
|
||||
|
||||
__all__ = ["UserPage", "UserAboutPage", "UserProblemsPage", "UserBookMarkPage", "users", "edit_profile"]
|
||||
__all__ = [
|
||||
"UserPage",
|
||||
"UserAboutPage",
|
||||
"UserProblemsPage",
|
||||
"UserBookMarkPage",
|
||||
"users",
|
||||
"edit_profile",
|
||||
]
|
||||
|
||||
|
||||
def remap_keys(iterable, mapping):
|
||||
|
@ -350,22 +357,19 @@ 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
|
||||
|
||||
bookmark_list = MakeBookMark.objects.filter(user=self.object)
|
||||
context["blogs"] = bookmark_list.filter(bookmark__page__startswith="b")
|
||||
context["problems"] = bookmark_list.filter(bookmark__page__startswith="p")
|
||||
context["contests"] = bookmark_list.filter(bookmark__page__startswith="c")
|
||||
context["solutions"] = bookmark_list.filter(bookmark__page__startswith="s")
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue