def get(self, request): page_params, order, reverse, count = gen_page_query_params(request, 50) params = {'media_id': self.media_id, 'status': STATUS_PUBLISHED} params.update(page_params) articles, has_next_page = gen_current_page_items(Article, params, order, reverse, count) status, reason, comment_counts = comments_processor.get_comments_count_by_article(articles) if not status: raise CommentsGetError return gen_page_response(comment_counts, has_next_page)
def get(self, request, article_id): data = request.GET read_tag = data.get('read_tag', '') count = data.get('count', COMMENTS_PAGE_COUNT_MAX) action = data.get('action', 'next') article = Article.objects(id=article_id, status=STATUS_PUBLISHED).first() status, reason, data = comments_processor.get_comments_by_article(article, read_tag, int(count), action) if not status: raise CommentsGetError return gen_page_response(data['comments'], data['has_next_page'])
def _get(self, request, article_status=None, type=None): params = {'media_id': self.media_id} if type is not None: params['type__in'] = NOTIFICATION_TYPE_MAPPING[type] if article_status: params['status'] = NAME_STATUS_MAPPING.get(article_status) page_params, order, reverse, count = gen_page_query_params(request) params.update(page_params) notifications, has_next_page = gen_current_page_items( Notification, params, order, reverse, count) return gen_page_response([NotificationCompactSerializer(notification).data \ for notification in notifications], has_next_page)
def get(self, request): media = request.user.get_related_media_account() params = {} page_params, order, reverse, count = gen_page_query_params(request, 20) params['father_media_id'] = str(media.id) params.update(page_params) mpls, has_next_page = gen_current_page_items(MediaPromotionLog, params, order, reverse, count) wrap_medianame = MediaNameGenerator(mpls) return gen_page_response( [wrap_medianame(PromotionLogSerializer(mpl)).data for mpl in mpls], has_next_page)
def get(self, request): page_params, order, reverse, count = gen_page_query_params(request) start_time, end_time, count = self.process_get_params(request) params = { 'site_url': self.media_account.site_url, 'start_date__gte': str(start_time.date()), 'end_date__lt': str(end_time.date()) } params.update(page_params) weekly_incomes, has_next_page = gen_current_page_items( WeeklyMediaIncome, params, order, reverse, count) return gen_page_response( [WeeklyIncomeSerializer(wi).data for wi in weekly_incomes], has_next_page)
def get(self, request): page_params, order, reverse, count = gen_page_query_params(request) start_time, end_time, count = self.process_get_params(request) start_time -= INDIA_TIME_DELTA end_time -= INDIA_TIME_DELTA params = { 'media_id': self.media_id, 'create_at__gte': start_time, 'create_at__lt': end_time } params.update(page_params) bonus, has_next_page = gen_current_page_items(Bonus, params, order, reverse, count) return gen_page_response([BonusSerializer(bn).data for bn in bonus], has_next_page)
def get(self, request): params = {} type = int(request.GET.get('type') or 0) if not type in ANN_TYPE_MAPPING: raise ParamError params['type'] = type page_params, order, reverse, count = gen_page_query_order_modified_time( request, 20) params['status'] = ANN_STATUS_USABLE params.update(page_params) announcements, has_next_page = gen_current_page_items( Announcement, params, order, reverse, count) return gen_page_response( [AnnouncementSerializer(ann).data for ann in announcements], has_next_page)
def _get(self, request, article_status=None): page_params, order, reverse, count = gen_article_page_query_params( request, 20) params = {'media_id': self.media_id} if article_status: params['status'] = NAME_STATUS_MAPPING.get(article_status) else: params['status__in'] = USABLE_STATUSES params.update(page_params) articles, has_next_page = gen_current_page_items( Article, params, order, reverse, count) has_syncing_finished = stat_utils.has_showing_data_synced() wrap_realtime = RealTimeStatisticsGenerator(articles, has_syncing_finished) return gen_page_response([wrap_realtime(ArticleStatisticSerializer(article, has_syncing_finished)).data \ for article in articles], has_next_page)
def get(self, request): page_params, order, reverse, count = gen_page_query_params(request) start_time, end_time, count = self.process_get_params(request) start_time -= INDIA_TIME_DELTA end_time -= INDIA_TIME_DELTA params = { 'media_id': self.media_id, 'published_at__gte': start_time, 'published_at__lt': end_time, 'status__in': [STATUS_PUBLISHED, STATUS_OFFLINE, STATUS_ADMIN_OFFLINE] } params.update(page_params) stats, has_next_page = gen_current_page_items(Article, params, order, reverse, count) return gen_page_response([ArticleCompactStatisticSerializer(stat).data \ for stat in stats], has_next_page)