示例#1
0
    def get_context_data(self, **kwargs):
        context = super(QuestionDetailView, self).get_context_data(**kwargs)
        History.generate_history(self.object, self.request)

        if self.object.kw:
            words = [self.object.title] + self.object.kw
            _re = r'(%s)' % ('|'.join(words))
            related_question = Question.objects.filter(Q(body__regex=_re) | Q(title__regex=_re)).exclude(
                id=self.object.id)[:20]
            context['related_question'] = related_question
        context['invites'] = Invite.objects.filter(content_type=ContentType.objects.get_for_model(self.object), object_id=self.object.id)
        return context
示例#2
0
    def get_context_data(self, **kwargs):
        context = super(QuestionDetailView, self).get_context_data(**kwargs)
        History.generate_history(self.object, self.request)

        if self.object.kw:
            words = [self.object.title] + self.object.kw
            _re = r'(%s)' % ('|'.join(words))
            related_question = Question.objects.filter(
                Q(body__regex=_re)
                | Q(title__regex=_re)).exclude(id=self.object.id)[:20]
            context['related_question'] = related_question
        context['invites'] = Invite.objects.filter(
            content_type=ContentType.objects.get_for_model(self.object),
            object_id=self.object.id)
        return context
示例#3
0
文件: views.py 项目: zouyapeng/BBS
 def get(self, request, *args, **kwargs):
     response = super(ArticleDetailView, self).get(request, *args, **kwargs)
     History.generate_history(self.object, request)
     return response
示例#4
0
 def get(self, request, *args, **kwargs):
     response = super(UserDetailView, self).get(request, *args, **kwargs)
     if self.object != request.user:
         History.generate_history(self.object, request)
     return response
示例#5
0
 def get(self, request, *args, **kwargs):
     response = super(ArticleDetailView, self).get(request, *args, **kwargs)
     History.generate_history(self.object, request)
     return response
示例#6
0
 def get(self, request, *args, **kwargs):
     response = super(UserDetailView, self).get(request, *args, **kwargs)
     if self.object != request.user:
         History.generate_history(self.object, request)
     return response