diff --git a/vro/public/views.py b/vro/public/views.py index b33b728..e2e780b 100644 --- a/vro/public/views.py +++ b/vro/public/views.py @@ -15,7 +15,7 @@ url_for, session ) -from flask_paginate import Pagination, get_page_parameter +from flask_paginate import Pagination from sqlalchemy.exc import DataError from sqlalchemy.orm.exc import NoResultFound @@ -85,22 +85,28 @@ def browse_all(): size = 50 q_list = [] + # "Search by Year" for Search by Year Function/Parameter + year_value = request.args.get("year", "") + year_range_value = request.args.get("year_range", "") + + if year_value: + q_list.append(Q("range", year={"gte": int(year_value), "lte": int(year_value)})) + year_range_value = f"{year_value} - {year_value}" + elif year_range_value and " to " in year_range_value: # Only process range if it contains "to" + year_range = [int(year.strip()) for year in year_range_value.split("to") if year.strip().isdigit()] + if len(year_range) == 2: + q_list.append(Q("range", year={"gte": year_range[0], "lte": year_range[1]})) + for key, value in [ ("cert_type", request.args.get("certificate_type", "")), ("number", request.args.get("number", "").lstrip("0")), ("county", request.args.get("county", "")), - ("year", request.args.get("year", "")), - ("year_range", request.args.get("year_range", "")), ("first_name", request.args.get("first_name", "")), ("last_name", request.args.get("last_name", "")) ]: if value: - if key == "year_range": - year_range = [int(year) for year in value.split() if year.isdigit()] - q_list.append(Q("range", year={"gte": year_range[0], "lte": year_range[1]})) - elif key in ["first_name", "last_name"]: + if key in ["first_name", "last_name"]: q_list.append(Q("multi_match", query=value.capitalize(), fields=[key, "spouse_"+key])) - # Marriage certificates and marriage licenses are considered the same record type to the user elif key == "cert_type" and value == "marriage": q_list.append(Q("terms", cert_type=[certificate_types.MARRIAGE, certificate_types.MARRIAGE_LICENSE])) else: @@ -138,15 +144,18 @@ def browse_all(): # Calculate total pages # total_pages = min((count + size - 1) // size, 200) - This was a previous version of what I had, newer is below# total_pages = (count + size - 1) // size + + # Flag for no results when going past a certain page + no_results = False # This is the condition to get rid of the page loop if page > total_pages and total_pages > 0: - query_params = request.args.to_dict() - query_params['page'] = total_pages - return redirect(url_for('public.browse_all', **query_params)) + no_results = True + + # Handle the case when the page is less than 1 elif page < 1: query_params = request.args.to_dict() - query_params['page'] = 1 + query_params['page'] = 1 return redirect(url_for('public.browse_all', **query_params)) # Flask Pagination Stuff @@ -188,6 +197,10 @@ def browse_all(): value = "First Name: {}".format(value) elif key == "last_name": value = "Last Name: {}".format(value) + """ + elif key == "year": + value = f"Year: {value}" + """ # Handle new URL current_args.pop(key) @@ -204,8 +217,8 @@ def browse_all(): form=form, year_range_min=cached_year_range.year_min, year_range_max=cached_year_range.year_max, - year_min_value=year_range[0] if request.args.get("year_range", "") else cached_year_range.year_min, - year_max_value=year_range[1] if request.args.get("year_range", "") else cached_year_range.year_max, + year_min_value=int(year_value) if year_value else (year_range[0] if year_range_value and " to " in year_range_value else cached_year_range.year_min), + year_max_value=int(year_value) if year_value else (year_range[1] if year_range_value and " to " in year_range_value else cached_year_range.year_max), certificates=res, page=page, has_prev=has_prev, @@ -215,6 +228,7 @@ def browse_all(): total_documents=format(count, ",d"), remove_filters=remove_filters, pagination=pagination, + no_results=no_results, certificate_types=certificate_types) @@ -303,4 +317,12 @@ def faq(): """ FAQ page """ - return render_template("public/faq.html") \ No newline at end of file + return render_template("public/faq.html") + + +""" +@blueprint.route('/browse-ledgers') +def browse_ledgers(): + Displaying Ledgers Page + return render_template('public/browse_ledgers.html') +""" \ No newline at end of file diff --git a/vro/search/utils.py b/vro/search/utils.py index a915c4c..6876443 100644 --- a/vro/search/utils.py +++ b/vro/search/utils.py @@ -102,7 +102,7 @@ def create_docs(): FROM certificates LEFT OUTER JOIN marriage_data AS marriage_data_1 ON certificates.id = marriage_data_1.certificate_id WHERE certificates.filename IS NOT NULL - GROUP BY certificates.id limit 500000; + GROUP BY certificates.id; """) count = 0 diff --git a/vro/static/css/style.css b/vro/static/css/style.css index 5c09d2a..2766ebc 100644 --- a/vro/static/css/style.css +++ b/vro/static/css/style.css @@ -196,6 +196,15 @@ ul a { outline: 0; border-width: 0 0 2px; border-color: #a9a9a9; + font-weight: bold; + font-size: 20px; + color: #111111; +} + +#skip-to-page { + background-color: #ffffff; + font-weight: bold; + color: #111111; } #homepage-year-range { diff --git a/vro/static/css/theme.css b/vro/static/css/theme.css index 79dd0f8..12bf796 100644 --- a/vro/static/css/theme.css +++ b/vro/static/css/theme.css @@ -2135,6 +2135,7 @@ textarea.form-control { .form-group { margin-bottom: 3rem; + font-weight: bold; } .form-text { diff --git a/vro/templates/public/browse_all.html b/vro/templates/public/browse_all.html index e918de4..29f6613 100644 --- a/vro/templates/public/browse_all.html +++ b/vro/templates/public/browse_all.html @@ -53,6 +53,21 @@

{{ total_documents }} Vital Record Results

+ + {# Commented Out - Search by Year Parameter +
+
+
+ +

Search by Year:

+ + +
+
+ #} + {% if remove_filters %} @@ -83,29 +98,47 @@

{{ total_documents }} Vital Record Results


- {% if num_results != "0" %} + {% if no_results %} +
+
+

+ There are no results for your search. Read our + Search Tips or see + + Digital Vital Records + for what you can find on this site. +

+

+ Please note that the "No Results" message is generated when there is + not a digitized image associated with the search. Future versions of + this application will return the certificate number (if found) along + with instructions on how to view/order a copy of the certificate + pending digitization. +

+
+
+{% elif num_results != "0" %}
{% include "public/_browse_all_results.html" %}
- {% else %} +{% else %}
-
-

- There are no results for your search. Read our - Search Tips or see - Digital Vital Records - for what you can find on this site. -

-

- Please note that the "No Results" message is generated when there is - not a digitized image associated with the search. Future versions of - this application will return the certificate number (if found) along - with instructions on how to view/order a copy of the certificate - pending digitization. -

-
+
+

+ There are no results for your search. Read our + Search Tips or see + + Digital Vital Records + for what you can find on this site. +

+

+ Please note that the "No Results" message is generated when there is + not a digitized image associated with the search. Future versions of + this application will return the certificate number (if found) along + with instructions on how to view/order a copy of the certificate + pending digitization. +

+
- {% endif %} +{% endif %} {% if num_results != "0" %} @@ -117,7 +150,7 @@

{{ total_documents }} Vital Record Results

{{ pagination.info.replace('displaying', 'Displaying') }}

-

Skip to Page:

+

Skip to Page: