def get_context_data(self, request, **kwargs):
     context = super(AttributeWordView, self).get_context_data(request, **kwargs)
     dataset = context['dataset']
     analysis = context['analysis']
     attribute = context['attribute']
     value = context['value']
     word = Word.objects.get(dataset=dataset, type=kwargs['word'])
     documents = word.document_set.filter(attribute=attribute,
             attributevaluedocument__value=value)
     words = []
     for document in documents:
         w = WordSummary(word.type)
         set_word_context(w, document, analysis)
         words.append(w)
         w.url = '%s/%s/values/%s/documents/%d?kwic=%s' \
             % (context['attributes_url'], attribute.name, value.value,
                document.id, word.type)
         w.doc_name = document.filename
         w.doc_id = document.id
 
     context['words'] = words
     context['breadcrumb'].word(word)
     context['attribute_post_link'] = '/words/%s' % word.type
 
     return context
Exemple #2
0
 def get_context_data(self, request, **kwargs):
     dataset_name = kwargs['dataset']
     analysis_name = kwargs['analysis']
     word = Word.objects.get(dataset__name=dataset_name, type=kwargs['word'])
     
     filter = TopicFilterByWord(Analysis.objects.get(dataset__name=dataset_name,
             name=analysis_name), 0)
     filter.current_word = word
     
     context = super(TopicWordView, self).get_context_data(request, extra_filters=[filter], **kwargs)
     analysis = context['analysis']
     topic = context['topic']
     context['word'] = word
     documents = word.documenttopicword_set.filter(topic=topic).order_by(
             'document__filename')
     docs = []
     for dtw in documents:
         d = dtw.document
         w = WordSummary(word.type)
         set_word_context(w, d, analysis, topic.number)
         docs.append(w)
         w.url = "%s/%d/documents/%d?kwic=%s" % (context['topics_url'],
                 topic.number, d.id, word.type)
         w.doc_name = d.filename
         w.doc_id = d.id
     context['documents'] = docs
     context['breadcrumb'].word(word)
     context['topic_post_link'] = '/words/%s' % word.type
     
     word_url = '%s/%d/words/' % (context['topics_url'], topic.number)
     context['tabs'] = [self._topic_word_tab(analysis, word, word_url, context['IMAGES'])]
     
     return context