Esempio n. 1
0
def detail(request, topic_id):
    topic = Fetcher.search_topic(Fetcher(), topic_id)

    saved_topic = Topic.objects.filter(guid = topic_id).exists()

    if saved_topic:
        saved_topic = Topic.objects.get(guid = topic_id)
        topic['topic_group']  = saved_topic.group

    if not topic:
        raise Http404

    related_topics = Fetcher.search_related_topics(Fetcher(), topic_id)

    data = {'topic' : topic, 'related_topics' : related_topics}
    context = RequestContext(request)
    context.update(data)

    return render_to_response('newscred/detail.html', context)
Esempio n. 2
0
def index(request):
    query_string = request.GET.get('query_string', '')

    topics = None
    if query_string:
      topics = Fetcher.search_topics(Fetcher(), query_string)

    if topics:
        for index, val in enumerate(topics):
            title =  get_edited_topic_name(val['guid'])
            if title:
                topics[index]['topic_group'] = title

    data = {'topics' : topics}
    context = RequestContext(request)
    context.update(data)

    return render_to_response('newscred/index.html', context)
 def render(self, context):
     self.guid = self.guid.resolve(context)
     topic = Fetcher.search_topic(Fetcher(), self.guid)
     return mark_safe("<div class='topic'><div class='topic_thumb'><img src='%s'/></div>%s<br/>URL: <a href='%s'>%s</a></div>" %
                      (topic['image_url'], topic['description'], topic['link'], topic['link'], ) )