mirror of https://github.com/interlegis/sapl.git
7 changed files with 108 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
|
|||
from haystack import indexes |
|||
from sapl.materia.models import DocumentoAcessorio |
|||
|
|||
class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): |
|||
text = indexes.CharField(document=True, use_template=True) |
|||
nome = indexes.CharField(model_attr='nome') |
|||
autor = indexes.CharField(model_attr='autor') |
|||
|
|||
# def prepare(self, obj): |
|||
# data = super(DocumentoAcessorioIndex, self).prepare(obj) |
|||
# if obj.arquivo is not None: |
|||
# file_data = self._get_backend(None).extract_file_contents( |
|||
# obj.arquivo, |
|||
# ) |
|||
# template = loader.select_template( |
|||
# ("search/indexes/materia/documentoacessorio_text.txt", ), |
|||
# ) |
|||
# |
|||
# data["text"] = template.render(Context({ |
|||
# "object": obj, |
|||
# "file_data": file_data, |
|||
# })) |
|||
# |
|||
# return data |
|||
|
|||
def get_model(self): |
|||
return DocumentoAcessorio |
|||
|
|||
def index_queryset(self, using=None): |
|||
return self.get_model().objects.all() |
|||
@ -0,0 +1,7 @@ |
|||
{{ object.tipo.sigla }} |
|||
{{ object.tipo.descricao }} |
|||
{{ object.materia.numero}} |
|||
{{ object.materia.ano}} |
|||
{{ object.nome }} |
|||
{{ object.data }} |
|||
{{ object.ementa }} |
|||
@ -0,0 +1,42 @@ |
|||
{% extends "crud/detail.html" %} |
|||
{% block detail_content %} |
|||
<h2>Search</h2> |
|||
|
|||
<form method="get" action="."> |
|||
<table> |
|||
{{ form.as_table }} |
|||
<tr> |
|||
<td> </td> |
|||
<td> |
|||
<input type="submit" value="Search"> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
{% if query %} |
|||
<h3>Results</h3> |
|||
|
|||
{% for result in page.object_list %} |
|||
<p> |
|||
<a href="{{ result.object.get_absolute_url }}"> |
|||
{{ result.object.materia.numero}}/ |
|||
{{ result.object.materia.ano }} - |
|||
{{ result.object.ementa }} |
|||
</a> |
|||
</p> |
|||
{% empty %} |
|||
<p>No results found.</p> |
|||
{% endfor %} |
|||
|
|||
{% if page.has_previous or page.has_next %} |
|||
<div> |
|||
{% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Anterior{% if page.has_previous %}</a>{% endif %} |
|||
| |
|||
{% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Próximo »{% if page.has_next %}</a>{% endif %} |
|||
</div> |
|||
{% endif %} |
|||
{% else %} |
|||
{# Show some example queries to run, maybe query syntax, something else? #} |
|||
{% endif %} |
|||
</form> |
|||
{% endblock %} |
|||
Loading…
Reference in new issue