def article(request, article_no=None, article_url=None): if not article_url or not article_no: raise Http404 article = get_object_or_none(Article, id=article_no) if not article: raise Http404 if not article_url == generate_seo_link(article.get_heading()): raise Http404 context = {} context['heading'] = article.get_heading() context['link'] = article.link article_viewed(request, article_no) return render(request, 'newsreader/article.html', context)
def get_ticker_feed(request): logger.info("Re-fetching ticker feed.") top_ten = cache.cache.get("top_ten_cache", {}) top_ten_articles = [] for article_id in top_ten: article = feed_models.Article.objects.get(id=article_id) if not article: return top_ten_articles.append( ( article.heading, reverse( "newsreader:article", kwargs={"article_url": generate_seo_link(article.get_heading()), "article_no": article.id}, ), str(article.link), ) ) logger.info("Sending response(get_ticker_feed)") return simplejson.dumps({"articles": top_ten_articles})
def get_article(request, tab_id, article_no): logger.debug("Ajax request received.(Tab_id: %s, Article_no: %s)" % (tab_id, article_no)) article = None success = False if request.user.is_authenticated(): logger.info("Retreiving articles") articles = get_content(request.user, tab_id) logger.info("No of articles retreived: %d" % len(articles)) if articles and len(articles) >= article_no: article = articles[article_no - 1] success = True logger.info("Article no %s found : %s" % (article_no, article.get_heading())) article = { 'id': article.id, 'title': article.get_heading(), 'mlink': article.link, 'link': reverse('newsreader:article', kwargs={'article_url': generate_seo_link(article.get_heading()), 'article_no': article.id}), 'pubDate': format_datetime(article.pub_date), 'summary': article.get_summary(), 'tags':[tag.name for tag in article.tags.all()] } else: article = { 'no_articles': True } logger.debug("Sending response(%s)" % str(article)) response = {'success': success, 'article': article} return simplejson.dumps(response)