def render(self, context, instance, placeholder): """ Render the latest news """ news = utils.get_news(instance.get_cache_path()) if instance.last_detailed: obj = news[0] self.render_template = "news_remote_detailed.html" context.update({"object":obj}) else: latest = news[:instance.limit] for news_item in latest: news_item.news_remote_link = reverse( "remote_news_detail", kwargs={"plugin_id":instance.id, "slug":news_item.slug}) context.update({ 'instance': instance, 'latest': latest, 'placeholder': placeholder, }) return context
def news_detail(request, **kwargs): template = "news_detail.html" plugin = Plugin.objects.get(id = kwargs["plugin_id"]) news = utils.get_news(plugin.get_cache_path()) news_object = None for news_item in news: if kwargs["slug"] == news_item.slug: news_object = news_item news_item.news_remote_link = reverse( 'remote_news_detail', kwargs={'plugin_id':plugin.id, 'slug':news_item.slug}) template_data = { "object":news_object, "latest":news} template_context = RequestContext(request, template_data) template_filled = loader.get_template(template) output = template_filled.render(template_context) response = HttpResponse(output, mimetype=None) return response