correct tags in search V01.56
authorymh <ymh.work@gmail.com>
Wed, 13 May 2015 02:07:46 +0200
changeset 1371 17b7a6d9959d
parent 1370 166d4c070210
child 1372 b82668d5bc1c
correct tags in search
src/ldt/ldt/indexation/__init__.py
src/ldt/ldt/ldt_utils/models.py
src/ldt/ldt/ldt_utils/templates/front/front_search_results.html
--- a/src/ldt/ldt/indexation/__init__.py	Tue May 12 14:40:49 2015 +0200
+++ b/src/ldt/ldt/indexation/__init__.py	Wed May 13 02:07:46 2015 +0200
@@ -71,14 +71,14 @@
                 #TODO :                 
                 highlighted_text = {
                      "context" : segment.highlighted.get('abstract',[segment.abstract])[0],
-                     "tags" : segment.highlighted.get('tags',[segment.tags])[0],
+                     "tags" : segment.highlighted.get('tags',[segment.get_tags()])[0],
                      'title' : segment.highlighted.get('title',[segment.title])[0],
                 }
 
             else:
                 highlighted_text = {
                      "context" : highlight.highlight(segment.abstract),
-                     "tags" : highlight.highlight(segment.tags),
+                     "tags" : highlight.highlight(segment.get_tags()),
                      'title' : highlight.highlight(segment.title)
                 }
                 
--- a/src/ldt/ldt/ldt_utils/models.py	Tue May 12 14:40:49 2015 +0200
+++ b/src/ldt/ldt/ldt_utils/models.py	Wed May 13 02:07:46 2015 +0200
@@ -853,6 +853,9 @@
             
         return value.pop()
     
+    def get_tags(self):
+        return ", ".join([t.name for t in self.tags.all()])
+    
     def set_hash(self):
         try:
             self.id_hash = generate_hash(self.__unicode__())
@@ -867,7 +870,7 @@
             unicode(self.cutting_id if self.cutting_id is not None else ""),
             unicode(self.element_id if self.element_id is not None else "")
             ))
-            
+    
     def save(self, *args, **kwargs):
         self.set_hash()                
         super(Segment, self).save(*args, **kwargs)
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Tue May 12 14:40:49 2015 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Wed May 13 02:07:46 2015 +0200
@@ -141,9 +141,9 @@
                             <h4><a class="pink under b" href="{% url 'ldt.ldt_utils.views.front.annot_content' content_iri_id=segment.iri_id project_id=segment.project_id cutting_id=segment.cutting_id %}#id={{segment.element_id}}" title="{% trans 'view this annotation in the player' %}">
                             {% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}</a></h4>
                             <p class="bigmargin">{% if segment.context %}{{ segment.context }}{% else %}{{ segment.abstract }}{% endif %}</p>
-                            {% if segment.context_tags or segment.tags %}
+                            {% if segment.context_tags or segment.tags.all %}
                             	<h5>Tags:</h5>
-                            	<p class="result_taglist b fl">{% if segment.context_tags %}{{ segment.context_tags }}{% else %}{{ segment.tags }}{% endif %}</p>
+                            	<p class="result_taglist b fl">{% if segment.context_tags %}{{ segment.context_tags }}{% else %}{{ segment.get_tags }}{% endif %}</p>
                             {% endif %}
                         </div>
                     </li>