IlyaGusev/PoetryCorpus

View on GitHub
poetry/templates/search/search.html

Summary

Maintainability
Test Coverage
{% extends 'base.html' %}
{% block search_active %} class="active" {% endblock %}
{% block content %}
<div class="page-header">
    <h3>Поиск</h3>
</div>
<div class="row">
    <div class="col-large-12">
        <form class="form-horizontal" method="get" action=".">
            <div class="form-group row">
                <div class="col-md-6 col-md-offset-3">
                    <input id="id_q" name="q" class="form-control"  type="search" placeholder="Искать по автору, названию, тексту">
                </div>
            </div>
            <div class="form-group row">
                <div class="col-md-offset-3 col-md-6">
                    <center>
                        <button type="submit" class="btn btn-primary" value="Search">Искать</button>
                    </center>
                </div>
            </div>
        </form>
        {% if query %}
            <h3>Результаты:</h3>
            {% include "pagination.html" with page_obj=page %}
             <table class="table table-hover">
                <thead>
                    <th width="25%">Автор</th>
                    <th width="60%">Название</th>
                </thead>
                {% for result in page.object_list %}
                <tr>
                    <td>{{ result.object.author }}</td>
                    <td><a href="{% url 'corpus:poem' pk=result.object.pk %}">{{ result.object.get_name }}</a></td>
                </tr>
                {% endfor %}
            </table>
            {% include "pagination.html" with page_obj=page %}
        {% endif %}
    </div>
</div>

{% endblock %}