Migrate pagevote and bookmark to use content_type
This commit is contained in:
parent
64495be799
commit
36e27321f7
19 changed files with 285 additions and 87 deletions
|
@ -109,9 +109,6 @@ class PostList(HomeFeedView):
|
|||
context["page_type"] = "blog"
|
||||
return context
|
||||
|
||||
def get_comment_page(self, post):
|
||||
return "b:%s" % post.id
|
||||
|
||||
|
||||
class TicketFeed(HomeFeedView):
|
||||
model = Ticket
|
||||
|
@ -180,9 +177,6 @@ class PostView(TitleMixin, CommentedDetailView, PageVoteDetailView, BookMarkDeta
|
|||
def get_title(self):
|
||||
return self.object.title
|
||||
|
||||
def get_comment_page(self):
|
||||
return "b:%s" % self.object.id
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PostView, self).get_context_data(**kwargs)
|
||||
context["og_image"] = self.object.og_image
|
||||
|
|
|
@ -71,6 +71,6 @@ def undobookmark_page(request):
|
|||
class BookMarkDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(BookMarkDetailView, self).get_context_data(**kwargs)
|
||||
queryset = BookMark.objects.get_or_create(page=self.get_comment_page())
|
||||
context["bookmark"] = queryset[0]
|
||||
queryset = self.object.bookmark
|
||||
context["bookmark"] = queryset.first()
|
||||
return context
|
||||
|
|
|
@ -412,9 +412,6 @@ class ContestDetail(
|
|||
):
|
||||
template_name = "contest/contest.html"
|
||||
|
||||
def get_comment_page(self):
|
||||
return "c:%s" % self.object.key
|
||||
|
||||
def get_title(self):
|
||||
return self.object.name
|
||||
|
||||
|
|
|
@ -270,9 +270,6 @@ class OrganizationHome(OrganizationHomeView, FeedView):
|
|||
.prefetch_related("authors__user", "organizations")
|
||||
)
|
||||
|
||||
def get_comment_page(self, post):
|
||||
return "b:%s" % post.id
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(OrganizationHome, self).get_context_data(**kwargs)
|
||||
context["title"] = self.organization.name
|
||||
|
|
|
@ -101,6 +101,6 @@ class PageVoteDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PageVoteDetailView, self).get_context_data(**kwargs)
|
||||
queryset = PageVote.objects.get_or_create(page=self.get_comment_page())
|
||||
context["pagevote"] = queryset[0]
|
||||
queryset = self.object.pagevote
|
||||
context["pagevote"] = queryset.first()
|
||||
return context
|
||||
|
|
|
@ -224,9 +224,6 @@ class ProblemSolution(
|
|||
context["has_solved_problem"] = self.problem.id in self.get_completed_problems()
|
||||
return context
|
||||
|
||||
def get_comment_page(self):
|
||||
return "s:" + self.problem.code
|
||||
|
||||
|
||||
class ProblemRaw(
|
||||
ProblemMixin, TitleMixin, TemplateResponseMixin, SingleObjectMixin, View
|
||||
|
@ -270,9 +267,6 @@ class ProblemDetail(
|
|||
context_object_name = "problem"
|
||||
template_name = "problem/problem.html"
|
||||
|
||||
def get_comment_page(self):
|
||||
return "p:%s" % self.object.code
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ProblemDetail, self).get_context_data(**kwargs)
|
||||
user = self.request.user
|
||||
|
@ -843,9 +837,6 @@ class ProblemFeed(ProblemList, FeedView):
|
|||
title = _("Problem feed")
|
||||
feed_type = None
|
||||
|
||||
def get_comment_page(self, problem):
|
||||
return "p:%s" % problem.code
|
||||
|
||||
# arr = [[], [], ..]
|
||||
def merge_recommendation(self, arr):
|
||||
seed = datetime.now().strftime("%d%m%Y")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue