# HG changeset patch # User ymh # Date 1431475666 -7200 # Node ID 17b7a6d9959daa95b31f36de368db7e07091d3e4 # Parent 166d4c070210e76356907f77a541fe22b83674e3 correct tags in search diff -r 166d4c070210 -r 17b7a6d9959d src/ldt/ldt/indexation/__init__.py --- 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) } diff -r 166d4c070210 -r 17b7a6d9959d src/ldt/ldt/ldt_utils/models.py --- 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) diff -r 166d4c070210 -r 17b7a6d9959d src/ldt/ldt/ldt_utils/templates/front/front_search_results.html --- 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 @@

{% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}

{% if segment.context %}{{ segment.context }}{% else %}{{ segment.abstract }}{% endif %}

- {% if segment.context_tags or segment.tags %} + {% if segment.context_tags or segment.tags.all %}
Tags:
-

{% if segment.context_tags %}{{ segment.context_tags }}{% else %}{{ segment.tags }}{% endif %}

+

{% if segment.context_tags %}{{ segment.context_tags }}{% else %}{{ segment.get_tags }}{% endif %}

{% endif %}