Browse Source

Inicia a pesquisa textual

pull/980/head
Eduardo Calil 9 years ago
committed by Edward Ribeiro
parent
commit
d9d88d5340
  1. 3
      sapl/base/search_indexes.py
  2. 21
      sapl/templates/search/search.html

3
sapl/base/search_indexes.py

@ -16,6 +16,7 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable):
return self.model
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
def prepare(self, obj):
@ -38,6 +39,8 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable):
extracted_data = extracted_data.replace('\t', ' ')
# Now we'll finally perform the template processing to render the
# text field with *all* of our metadata visible for templating:
t = loader.select_template((
'search/indexes/' + self.template_name, ))
data['text'] = t.render(Context({'object': obj,

21
sapl/templates/search/search.html

@ -4,7 +4,6 @@
{% block base_content %}
<h1><legend>Pesquisa Textual</legend></h1>
</br>
<form method="get" action=".">
@ -81,6 +80,24 @@
</tr>
{% endfor %}
</table>
{% if query %}
<h3>Resultados</h3>
{% for result in page.object_list %}
{% if result.object|search_get_model == 'm' %}
<p>
<a href="{% url 'sapl.materia:materialegislativa_detail' result.object.pk %}">{{ result.object }}</a>
</p>
{% elif result.object|search_get_model == 'd' %}
<p>
<a href="{% url 'sapl.materia:documentoacessorio_detail' result.object.pk %}">{{ result.object }}</a>
</p>
{% endif %}
{% empty %}
<p>No results found.</p>
{% endfor %}
{% if page.has_previous or page.has_next %}
<div>
@ -93,4 +110,4 @@
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
</form>
{% endblock %}
{% endblock %}

Loading…
Cancel
Save