Fixed bugs and removed unnecessary files

new_api
Rachel Kim 2020-05-06 00:08:19 -04:00
parent 67b0bd8717
commit d74d903225
7 changed files with 15 additions and 290 deletions

View File

@ -35,10 +35,6 @@ def create_app(test_config=None):
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/results')
def results():
return render_template('results.html')
@app.route('/help')
def help():

View File

@ -33,16 +33,14 @@ def index():
print("NO ARGUMENTS GIVEN. PLEASE GIVE ARGUMENTS")
else:
if request.args.get("renewal"):
results = ren_search(request.args['renewal'], request.args.get('page'),
request.args.get('per_page'))
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'))
unique = 1
if request.args.get("registration") and unique == 0:
results = reg_search(request.args['registration'], request.args.get('page'),
request.args.get('per_page'))
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'))
unique = 1 #technically not 100% unique but should be very simplified for now
unique = 1
if request.args.get("title") and unique==0:
params["title"] = request.args['title']
@ -62,96 +60,17 @@ def index():
if unique==0:
results = new_search(params, request.args.get('page'), request.args.get('per_page'))
paging = proc_pagination(results['data']['paging'], request.args.get('page'))
# if request.args.get("title") and unique == 0:
# title = request.args['title']
# tempResults = search(title, request.args.get('page'),
# request.args.get('per_page'))
# tempPaging = proc_pagination(tempResults['data']['paging'],
# request.args.get('page'))
# max_page = tempPaging['last_page']
# results = tempResults
# paging = tempPaging
# tempArgs = request.args['title']
# if request.args.get("author") and unique == 0:
# author = request.args['author']
# tempResults = search(author, request.args.get('page'),
# request.args.get('per_page'))
# tempPaging = proc_pagination(tempResults['data']['paging'],
# request.args.get('page'))
# if max_page > tempPaging['last_page'] or max_page == 0:
# max_page = tempPaging['last_page']
# results = tempResults
# paging = tempPaging
# tempArgs = request.args['author']
# if request.args.get("publisher") and unique == 0:
# publisher = request.args['publisher']
# tempResults = search(publisher, request.args.get('page'),
# request.args.get('per_page'))
# tempPaging = proc_pagination(tempResults['data']['paging'],
# request.args.get('page'))
# if max_page > tempPaging['last_page'] or max_page == 0:
# max_page = tempPaging['last_page']
# results = tempResults
# paging = tempPaging
# tempArgs = request.args['publisher']
# #Modifed Search Functionality
# for i in range(max_page):
# pageResults = proc_results(search(tempArgs, i, 10))
# for obj in pageResults:
# match_author = False
# match_title = False
# match_publisher = False
# if(title!=None):
# if(re.search(title, obj['title'], re.IGNORECASE)):
# match_title = True
# else:
# match_title = True
# if("type" in obj):
# if(author!=None):
# if(re.search(author, obj['author'], re.IGNORECASE)):
# match_author = True
# else:
# match_author = True
# else:
# if(author!=None):
# for a in obj['authors']:
# if(re.search(author, a, re.IGNORECASE)):
# match_author = True
# break
# else:
# match_author = True
# if(publisher!=None):
# for p in obj['publishers']:
# if(re.search(publisher, p, re.IGNORECASE)):
# match_publisher = True
# break
# else:
# match_publisher = True
# if(match_author and match_title and match_publisher):
# matched_results.append(obj)
# print(json.dumps(matched_results))
# print(len(matched_results))
# if max_page != 0:
# print("----------------------------------------------------------")
# procResults = proc_results(search(tempArgs, 0, results['data']['total']))
# print(procResults)
print("PRINTING PAGING HERE")
print(paging)
print("----------------------------------------------------------")
print("DATA PAGING")
print(results['data']['paging'])
results = proc_results(results)
# print("PRINTING PAGING HERE")
# print(paging)
# print("----------------------------------------------------------")
# print("DATA PAGING")
# print(results['data']['paging'])
# print(json.dumps(results))
# print("")
results = proc_results(results)
print(json.dumps(results))
print(json.dumps(results[0]["renewals"]))
if results == []:
print("NO RESULTS")

View File

@ -4,8 +4,8 @@
<div class="py-5 text-center">
<div class="content">
<h1>Need Help? (IN PROGRESS)</h1>
<p>Enter in the Title, Author, Publisher, Registration Number, Renewal Number or any combination of the previous options into your search.</p>
<p>Your search results should yield the registration(s) from your search parameters. Including its description, publishers and renewal history.</p>
<p>Enter a Title, Author, Publisher, Registration Number, Renewal Number or any combination of the previous options into the search inputs.</p>
<p>The search results should yield registrations and renewals from the database and provide information including its description, publishers, and renewal history.</p>
<p>If this work has been found to be out of copyright, then it is able to be distributed freely online.</p>
<br>
<h3>How to determine if a book is in the public domain:</h3>

View File

@ -1,53 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/static/styles.css">
<head>
<title>Copyright Renewals</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand">Copyright Renewals</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Search <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="about">About Us <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Copyrights <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">NYPL <span class="sr-only"></span></a>
</li>
</ul>
</div>
</nav>
<div class="bg">
<div class="results">
<h1>Static Results page</h1>
</div>
</div>
</body>
</html>

View File

@ -63,9 +63,6 @@
<tr>
<th scope="row">Renewals</th>
<td>
{% if result['is_post_1963'] %}
<em>Works published after 1963 do not require renewal and are in copyright</em>
{% else %}
{% if result['renewals'] %}
{% for renewal in result['renewals'] %}
{% include "search/render_child_renewal.html" %}
@ -73,7 +70,7 @@
{% else %}
<em>No renewals found</em>
{% endif %}
{% endif %}
{% if result['is_foreign'] %}
<br>See note on <a href="/registration-classes#foreign">Foreign publications</a>
{% endif %}

View File

@ -1,90 +0,0 @@
<<<<<<< HEAD
<div class = "d-flex"><h3>Title: {{ result['title'] }}</h3></div>
<dl>
=======
<div class = "d-flex"><h3>Registration {{ result['registrations'][0]['number'] }}</h3></div>
<dl>
<div class="row">
<div class="col col-sm-6"><b>Title</b></div>
<div class="col col-sm-6">{{ result['title'] }}</div>
</div>
>>>>>>> 64bb8e084d56712426a580424bbea10580ed97dc
<div class = "row">
<div class="col col-sm-6"><b>Authors</b></div>
{% for a in result['authors'] %}
<div class="col col-sm-6">-{{ a }}</div>
<div class="col-sm-6"> </div>
{% endfor %}
</div>
<div class="row">
<div class="col-sm-6"><b>Registrations</b></div>
{% for r in result['registrations'] %}
<div class="col-sm-6">-{{ r['number'] }} {{ r['date'] }}</div>
{% endfor %}
</div>
{% if result['copies'] %}
<dt>Copies</dt>
{{ result['copies'] }}
{% endif %}
{% if result['copy_date'] %}
<dt>Copy Date</dt>
{{ result['copy_date'] }}
{% endif %}
{% if result['description'] %}
<dt>Description</dt>
{{ result['description'] }}
{% endif %}
{% if result['pub_date'] %}
<dt>Publication Date</dt>
{{ result['pub_date'] }}
{% endif %}
{% if result['publishers'] %}
<dt>Publishers</dt>
{% for p in result['publishers'] %}
- {{ p }}<br>
{% endfor %}
{% endif %}
<dt>Renewals</dt>
{% if result['is_post_1963'] %}
<em>Works published after 1963 do not require renewal and are in copyright</em>
{% else %}
{% if result['renewals'] %}
{% for renewal in result['renewals'] %}
{% include "search/render_child_renewal.html" %}
{% endfor %}
{% else %}
<em>No renewals found</em>
{% endif %}
{% endif %}
{% if result['is_foreign'] %}
<p>See note on <a href="/registration-classes#foreign">Foreign publications</a></p>
{% endif %}
{% if result['is_interim'] %}
<p>See note on <a href="/registration-classes#interim">Interim registrations</a></p>
{% endif %}
<dt>Source</dt>
<a href="{{ result['source_url'] }}">
{{ result['source']['year'] }} p. {{ result['source']['page'] }}
</a>
<dt>Original</dt>
{{ result['original'] }}
<dt>CCEID</dt>
<a href="/cceid/{{ result['uuid'] }}">{{ result['uuid'] }}</a>
</dl>

View File

@ -1,44 +0,0 @@
<h2>Renewal {{ result['renewal_num'] }}</h2>
<dl class="grid-row">
<dt class="grid-col-2">Title</dt>
<dd class="grid-col-9">{{ result['title'] }}</dd>
<dt class="grid-col-2">Authors</dt>
<dd class="grid-col-9">{{ result['author'] }}</dd>
<dt class="grid-col-2">Renewal</dt>
<dd class="grid-col-9">
{{ result['renewal_num'] }} {{ result['renewal_date'] }}
</dd>
<dt class="grid-col-2">Claimants</dt>
<dd class="grid-col-9">
<ul class="usa-list usa-list--unstyled">
{% for c in result['claimants'] %}
<li>{{ c['name'] }} ({{ c['type'] }})</li>
{% endfor %}
</ul>
</dd>
{% if result['new_matter'] %}
<dt class="grid-col-2">New Matter</dt>
<dd class="grid-col-9">{{ result['new_matter'] }}</dd>
{% endif %}
{% if result['notes'] %}
<dt class="grid-col-2">Notes</dt>
<dd class="grid-col-9">{{ result['notes'] }}</dd>
{% endif %}
{% if result['source'] %}
<dt class="grid-col-2">Original</dt>
<dd class="grid-col-9">{{ result['source'] }}</dd>
{% endif %}
<dt class="grid-col-2">CCEID</dt>
<dd class="grid-col-9">
<a href="/cceid/{{ result['uuid'] }}">{{ result['uuid'] }}</a>
</dd>
</dl>