Beispiel #1
0
 def get_context_data(self, **kwargs):
     context = super(ArticleListView, self).get_context_data()
     object_list = list(context.get('object_list').only('id', 'bigv_id'))
     object_ids = map(lambda x: x.id, object_list)
     v_ids = list(set(map(lambda x: x.bigv_id, object_list)))
     cache_bigv(v_ids)
     cache_options(object_ids, self.request.session['openid'])
     return context
Beispiel #2
0
 def get_context_data(self, **kwargs):
     context = super(ArticleListView, self).get_context_data()
     object_list = list(context.get('object_list').only('id', 'bigv_id'))
     object_ids = map(lambda x: x.id, object_list)
     v_ids = list(set(map(lambda x: x.bigv_id, object_list)))
     cache_bigv(v_ids)
     cache_options(object_ids, self.request.session['openid'])
     return context
Beispiel #3
0
 def get_context_data(self, **kwargs):
     context = super(ArticleListForBigvView, self).get_context_data()
     object_list = list(context.get('object_list').only('id'))
     object_ids = map(lambda x: x.id, object_list)
     cache_options(object_ids, self.request.session['openid'])
     data = self.request.GET.copy()
     token = data.get('token')
     page = data.get('page')
     context.update({'token': token})
     context.update({'page': page})
     return context
Beispiel #4
0
 def get_context_data(self, **kwargs):
     content_type = ContentType.objects.get_for_model(ArticlePostedResults).id
     context_data = super(ArticleDetailView, self).get_context_data()
     context_data.update({'content_type': content_type})
     is_comments = self.object.comments.exists()
     if is_comments:
         comments = self.object.comments.select_related().only('content', 'created_datetime', 'wechatuser__nickname', 'wechatuser__headimgurl')
         context_data.update({'comments': comments})
     context_data.update({'is_comments': is_comments})
     cache_options([self.object.id], self.request.wechatuser.openid)
     return context_data
Beispiel #5
0
 def get_context_data(self, **kwargs):
     context = super(ArticleListForBigvView, self).get_context_data()
     object_list = list(context.get('object_list').only('id'))
     object_ids = map(lambda x: x.id, object_list)
     cache_options(object_ids, self.request.session['openid'])
     data = self.request.GET.copy()
     token = data.get('token')
     page = data.get('page')
     context.update({'token': token})
     context.update({'page': page})
     return context
Beispiel #6
0
 def get_context_data(self, **kwargs):
     context = super(MineJudgementListView, self).get_context_data()
     object_list = list(context.get('object_list').only('article_id'))
     object_ids = map(lambda x: x.article_id, object_list)
     object_list = ArticlePostedResults.active_objects.filter(id__in=object_ids).only('bigv_id', 'title', 'content', 'publish_date', 'article_source', 'score', 'is_correct')
     v_ids = list(set(map(lambda x: x.bigv_id, object_list)))
     cache_bigv(v_ids)
     cache_options(object_ids, self.request.session['openid'])
     context.update({'object_list': object_list})
     context.update({'token': 'judge'})
     data = self.request.GET.copy()
     jtype = data.get('jtype', 'due')
     context.update({'jtype': jtype})
     return context 
Beispiel #7
0
 def get_context_data(self, **kwargs):
     content_type = ContentType.objects.get_for_model(
         ArticlePostedResults).id
     context_data = super(ArticleDetailView, self).get_context_data()
     context_data.update({'content_type': content_type})
     is_comments = self.object.comments.exists()
     if is_comments:
         comments = self.object.comments.select_related().only(
             'content', 'created_datetime', 'wechatuser__nickname',
             'wechatuser__headimgurl')
         context_data.update({'comments': comments})
     context_data.update({'is_comments': is_comments})
     cache_options([self.object.id], self.request.wechatuser.openid)
     return context_data
Beispiel #8
0
 def get_context_data(self, **kwargs):
     context = super(MineJudgementListView, self).get_context_data()
     object_list = list(context.get('object_list').only('article_id'))
     object_ids = map(lambda x: x.article_id, object_list)
     object_list = ArticlePostedResults.active_objects.filter(
         id__in=object_ids).only('bigv_id', 'title', 'content',
                                 'publish_date', 'article_source', 'score',
                                 'is_correct')
     v_ids = list(set(map(lambda x: x.bigv_id, object_list)))
     cache_bigv(v_ids)
     cache_options(object_ids, self.request.session['openid'])
     context.update({'object_list': object_list})
     context.update({'token': 'judge'})
     data = self.request.GET.copy()
     jtype = data.get('jtype', 'due')
     context.update({'jtype': jtype})
     return context
Beispiel #9
0
 def get_context_data(self, **kwargs):
     context_data = super(PredictionView, self).get_context_data(**kwargs)
     queryset = self.get_queryset()
     data = queryset.values('viewpoint').annotate(value=Count('viewpoint'))
     for d in data:
         d.update({'name': dict(PREDICTION_VIEWPOINT_CHOICES)[d['viewpoint']].title()})
         d.update({'items': queryset.filter(viewpoint=d['viewpoint']).only(\
         'article__bigv_id', 'article__title', 'article__content', 'article__publish_date'\
         , 'article__article_source', 'bigv__name', 'bigv__words_weight', 'article__is_correct').order_by('-article__publish_date')})
     
     context_data.update({'data': data})
     object_list = context_data.get('object_list').only('article__id', 'bigv__v_id')
     cache_options(map(lambda x: x.article.id, object_list), self.request.wechatuser.openid)
     v_ids = list(set(map(lambda x: x.bigv.v_id, object_list)))
     cache_bigv(v_ids)
     is_subscribe = Subscribe.objects.filter(wechatuser=self.request.wechatuser, status='subscribe').exists()
     context_data.update({'is_subscribe': is_subscribe})
     return context_data
Beispiel #10
0
    def get_context_data(self, **kwargs):
        context_data = super(PredictionView, self).get_context_data(**kwargs)
        queryset = self.get_queryset()
        data = queryset.values('viewpoint').annotate(value=Count('viewpoint'))
        for d in data:
            d.update({
                'name':
                dict(PREDICTION_VIEWPOINT_CHOICES)[d['viewpoint']].title()
            })
            d.update({'items': queryset.filter(viewpoint=d['viewpoint']).only(\
            'article__bigv_id', 'article__title', 'article__content', 'article__publish_date'\
            , 'article__article_source', 'bigv__name', 'bigv__words_weight', 'article__is_correct').order_by('-article__publish_date')})

        context_data.update({'data': data})
        object_list = context_data.get('object_list').only(
            'article__id', 'bigv__v_id')
        cache_options(map(lambda x: x.article.id, object_list),
                      self.request.wechatuser.openid)
        v_ids = list(set(map(lambda x: x.bigv.v_id, object_list)))
        cache_bigv(v_ids)
        is_subscribe = Subscribe.objects.filter(
            wechatuser=self.request.wechatuser, status='subscribe').exists()
        context_data.update({'is_subscribe': is_subscribe})
        return context_data