Skip to content

Commit

Permalink
backup of code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-gray-tangent committed Jul 12, 2024
1 parent 1046909 commit 882a060
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 148 deletions.
23 changes: 23 additions & 0 deletions app/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,33 @@ def search(request):
except EmptyPage:
page_obj = paginator.page(paginator.num_pages)

search_params = pagination_url(request)

context = {
"search_results": paginator.page(page_obj.number),
"filter": f,
"documents": page_obj,
"search_params": search_params,
}

return render(request, template_name=template, context=context)


def pagination_url(
request,
):
url_params = {
"search": request.GET.get("search", ""),
"document_type": request.GET.get("document_type", ""),
"institution": request.GET.get("institution", ""),
"subjects": request.GET.get("subjects", ""),
"languages": request.GET.get("languages", ""),
}

return "?search={search}&document_type={document_type}&institution={institution}&subjects={subjects}&languages={languages}".format(
search=url_params["search"],
document_type=url_params["document_type"],
institution=url_params["institution"],
subjects=url_params["subjects"],
languages=url_params["languages"],
)
6 changes: 1 addition & 5 deletions app/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,10 @@ html {
}

/*Search Css*/
.subjects-checkbox-container {
.checkbox-container {
cursor: pointer;
max-height: 130px; /* Adjust based on your line-height and padding to show only 4 rows */
overflow-y: auto; /* Enable vertical scrollbar when content overflows */
border: 1px solid #ced4da; /* Bootstrap's form control border color */
border-radius: 0.25rem; /* Bootstrap's form control border radius */
}

.subjects-checkbox-container input[type="checkbox"] {
cursor: pointer;
}
277 changes: 134 additions & 143 deletions app/templates/app/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,165 +3,156 @@
{% load i18n %}

{% block content %}
<div class="body">
<div class="section mt-3 mb-3">
<div class="card content-card p-2">
<div class="card-body">
<h5 class="card-title">{% trans "Search a term" %}</h5>
<form method="get" class="container">
<input type="search" name="{{ filter.form.search.name }}" placeholder="{% trans 'Search...' %}"
class="form-control search-input"
value="{{ request.GET.search|default_if_none:'' }}">
<br>
<input type="submit" class="btn btn-success float-left"/>
</form>
<br>
<br>
<div class="container">
{% for document in search_results %}
<div>
<ul>
<li>
<span class="mr-5 text-primary"><b>{% trans "Title:" %}</b></span>
<span>{{ document.title }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>{% trans "Institution:" %}</b></span>
<span>{{ document.institution }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>{% trans "Headline:" %}</b></span>
<span>{{ document.search_headline|safe }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "File:" %}</b></span>
<span>{{ document.uploaded_file }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "License:" %}</b></span>
<span>{{ document.license }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "License:" %}</b></span>
<span>{{ document.document_type }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "Mime Type:" %}</b></span>
<span>{{ document.mime_type }}</span>
</li>
<li class="mt-2">
<span class="mr-5"><b>{% trans "Rank:" %}</b></span>
<span><i>{{ document.rank }}</i></span>
</li>
</ul>
</div>
{% endfor %}
</div>
</div>
<div class="container">
<hr>

<div class="body">
<div class="section mt-3 mb-3">
<div class="card content-card p-2">
<div class="card-body">
<h5 class="card-title">{% trans "Search a term" %}</h5>
{{ search_params }}
<div class="pagination ">
{% if documents.has_previous %}
<a href="{{ search_params }}&page=1">&laquo; first</a>
<a href="?page={{ documents.previous_page_number }}">&lt; previous</a>
{% endif %}
<span class="current">
Page {{ documents.number }} of {{ documents.paginator.num_pages }}.
</span>
{% if documents.has_next %}
<a href="{{ search_params }}&page={{ documents.next_page_number }}">next &gt;</a>
<a href="{{ search_params }} }}&page={{ documents.paginator.num_pages }}">last
&raquo;</a>
{% endif %}
</div>
<hr>
</div>
<form method="get" class="container">
<input type="search" name="{{ filter.form.search.name }}" placeholder="{% trans 'Search...' %}"
class="form-control search-input"
value="{{ request.GET.search|default_if_none:'' }}">
<br>
<input type="submit" class="btn btn-success float-left"/>
</form>
<br>
<br>
<div class="container">
{% for document in search_results %}
<div>
<ul>
<li>
<span class="mr-5 text-primary"><b>{% trans "Title:" %}</b></span>
<span>{{ document.title }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>{% trans "Institution:" %}</b></span>
<span>{{ document.institution }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>{% trans "Headline:" %}</b></span>
<span>{{ document.search_headline|safe }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "File:" %}</b></span>
<span>{{ document.uploaded_file }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "License:" %}</b></span>
<span>{{ document.license }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "License:" %}</b></span>
<span>{{ document.document_type }}</span>
</li>
<li>
<span class="mr-5"><b>{% trans "Mime Type:" %}</b></span>
<span>{{ document.mime_type }}</span>
</li>
<li class="mt-2">
<span class="mr-5"><b>{% trans "Rank:" %}</b></span>
<span><i>{{ document.rank }}</i></span>
</li>
</ul>
</div>
{% endfor %}
</div>
</div>
<div class="container">
<hr>
<div class="pagination ">
{% if documents.has_previous %}
<a href="?search={{ request.GET.search|default_if_none:'' }}
&document_type={{ request.GET.document_type|default_if_none:'' }}
&institution={{ request.GET.institution|default_if_none:'' }}
&subjects={{ request.GET.subjects|default_if_none:'' }}
&languages={{ request.GET.languages|default_if_none:'' }}&page=1">&laquo; first</a>
<a href="?page={{ documents.previous_page_number }}">&lt; previous</a>
{% endif %}
<span class="current">
Page {{ documents.number }} of {{ documents.paginator.num_pages }}.
</span>
{% if documents.has_next %}
<a href="?search={{ request.GET.search|default_if_none:'' }}
&document_type={{ request.GET.document_type|default_if_none:'' }}
&institution={{ request.GET.institution|default_if_none:'' }}
&subjects={{ request.GET.subjects|default_if_none:'' }}
&languages={{ request.GET.languages|default_if_none:'' }}
&page={{ documents.next_page_number }}">next &gt;</a>
<a href="?search=
{{ request.GET.search|default_if_none:'' }}&page={{ documents.paginator.num_pages }}">last
&raquo;</a>
{% endif %}
</div>
<hr>
</div>
<form method="get" class="container">
<input type="search" name="{{ filter.form.search.name }}" placeholder="{% trans 'Search...' %}"
class="form-control search-input"
value="{{ request.GET.search|default_if_none:'' }}">
<br>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Institution</label>
<div class="subjects-checkbox-container">
{% for checkbox in filter.form.institution %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label"
for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Institution</label>
<div class="checkbox-container">
{% for checkbox in filter.form.institution %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label"
for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Document Type</label>
<div class="subjects-checkbox-container">
{% for checkbox in filter.form.document_type %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Document Type</label>
<div class="checkbox-container">
{% for checkbox in filter.form.document_type %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Subjects</label>
<div class="subjects-checkbox-container">
{% for checkbox in filter.form.subjects %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Subjects</label>
<div class="checkbox-container">
{% for checkbox in filter.form.subjects %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Languages</label>
<div class="subjects-checkbox-container">
{% for checkbox in filter.form.languages %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
<div class="col-md-3">
<div class="form-group">
<label for="id_subjects">Languages</label>
<div class="checkbox-container">
{% for checkbox in filter.form.languages %}
<div class="form-check">
{{ checkbox.tag }}
<label class="form-check-label" for="{{ checkbox.id_for_label }}">
{{ checkbox.choice_label }}
</label>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
<br>
<input type="submit" class="btn btn-success float-left"/>
<br>
</form>
<br>
<input type="submit" class="btn btn-success float-left"/>
<br>
</form>
</div>
<br>
</div>
<br>
</div>
</div>

{% endblock content %}

0 comments on commit 882a060

Please sign in to comment.