def read_json(request): data = json.dumps({ 'news': [from_es_dict_dto(a) for a in store.get_articles('NewsArticle')], 'sports': [from_es_dict_dto(a) for a in store.get_articles('SportsArticle')], 'finance': [from_es_dict_dto(a) for a in store.get_articles('FinanceArticle')], 'entertainment': [from_es_dict_dto(a) for a in store.get_articles('EntertainmentArticle')], #'fNews': [from_es_dto(a) for a in store.get_featured_articles('NewsArticle')], #'fSports': [from_es_dto(a) for a in store.get_featured_articles('SportsArticle')], #'fFinance': [from_es_dto(a) for a in store.get_featured_articles('FinanceArticle')], #'fEntertainment': [from_es_dto(a) for a in store.get_featured_articles('EntertainmentArticle')], }, default=date_parser) return HttpResponse(data, mimetype='application/json')
def read(request): return render( request, 'read.html', { 'news': store.get_articles('NewsArticle', 40), 'sports': store.get_articles('SportsArticle', 40), 'finance': store.get_articles('FinanceArticle', 40), 'entertainment': store.get_articles('EntertainmentArticle', 40), 'featuredNews': store.get_headlines('NewsArticle', 40), 'featuredSports': store.get_headlines('SportsArticle', 40), 'featuredFinance': store.get_headlines('FinanceArticle', 40), 'featuredEntertainment': store.get_headlines('EntertainmentArticle', 40), })
def read_more(request, tag): page = int(request.GET.get('page', 1)) start = (page - 1) * 40 stop = page * 40 articles = store.get_articles(tag, stop, start) if not page: return HttpResponse(json.dumps( {'error': 'page not selected'}, default=date_parser), mimetype='application/json') return render(request, 'article_block.html', {'articles': articles})
def articles(request, tag): page = int(request.GET.get('page', 1)) cat = parse_tag(tag) start = (page - 1) * 40 stop = page * 40 articles = store.get_articles(tag, start=start, limit=stop) fudge = [utils.from_es_dict_dto(a) for a in articles] return HttpResponse(json.dumps({ 'articles': fudge, 'cat': cat, }, default=date_parser), mimetype='application/json' )