No results added and bugs fixed

pull/5/head
tmitche2 2020-04-14 22:15:02 -07:00
parent d94bcc91b8
commit f81c1eb10d
2 changed files with 15 additions and 22 deletions

View File

@ -27,7 +27,6 @@ def index():
print("NO ARGUMENTS GIVEN. PLEASE GIVE ARGUMENTS")
else:
if request.args.get("renewal"):
print("UNIQUE. THERE IS RENEWAL. NEED TO BREAK FROM THIS UNLESS NO RESULTS SHOW")
results = ren_search(request.args['renewal'], request.args.get('page'),
request.args.get('per_page'))
paging = proc_pagination(results['data']['paging'], request.args.get('page'))
@ -35,7 +34,6 @@ def index():
if request.args.get("registration") and unique == 0:
print("THERE IS REGISTRATION")
results = reg_search(request.args['registration'], request.args.get('page'),
request.args.get('per_page'))
paging = proc_pagination(results['data']['paging'], request.args.get('page'))
@ -50,7 +48,6 @@ def index():
if request.args.get("author") and unique == 0:
print("THERE IS AN AUTHOR")
results = search(request.args['author'], request.args.get('page'),
request.args.get('per_page'))
paging = proc_pagination(results['data']['paging'],
@ -58,7 +55,6 @@ def index():
if request.args.get("publisher") and unique == 0:
print("THERE IS AN PUBLISHER")
results = search(request.args['publisher'], request.args.get('page'),
request.args.get('per_page'))
paging = proc_pagination(results['data']['paging'],
@ -71,9 +67,12 @@ def index():
results = proc_results(results)
print(results)
#breaks if there are few results, or if you click on last page
#makes me think there's an issue with a for loop that is rendering the results since the last result won't display?
if results == []:
print("NO RESULTS")
noresults = 1
return render_template('search/index.html', noresults=noresults)
return render_template('search/index.html', results=results, term=title,
paging=paging, search_type=search_type)

View File

@ -2,20 +2,19 @@
{% block content %}
{% if results %}
{% include "search/paging.html" %}
{% for result in results %}
<div class = "results">
<!-- {% include "search/render_registration.html" %} -->
{% include "search/new_registration.html" %}
</div>
{% endfor %}
{% else %}
<div class="py-5 text-center">
<div class = "content">
<h1>Copyright Search</h1>
@ -29,19 +28,14 @@
<input type="text" name="renewal" placeholder="Renewal Number" autocomplete="off"><br>
<button type="submit" class="btn btn-secondary">Search</button>
</form>
{% if noresults %}
<br>
<div class="alert alert-danger" role="alert">No results found. Please try another search.</div>
{% endif %}
</div>
</div>
{% endif %}
{% if noresults %}
<div class = "results">
<h1>No Results Found.</h1>
<a href="/">Back To Search</a>
</div>
{% endif %}
{% include "search/paging.html" %}
{% endblock %}