diff --git a/wdfn-server/requirements.txt b/wdfn-server/requirements.txt index 9c4f1b13a315b1fc9cd89e9e1290fedbd76c8e90..e30a4a7d4c822c3a2d99f11db826915f5b791d72 100644 --- a/wdfn-server/requirements.txt +++ b/wdfn-server/requirements.txt @@ -1,5 +1,5 @@ certifi==2021.5.30 -Flask==1.1.4 +Flask==2.0.1 Markdown==3.3.4 MarkupSafe==2.0.1 pendulum==2.1.2 @@ -11,3 +11,4 @@ requests==2.26.0 requests-mock==1.9.3 six==1.16.0 SaltPyLint==2020.9.28 +ua-parser==0.10.0 diff --git a/wdfn-server/waterdata/templates/base_network.html b/wdfn-server/waterdata/templates/base_network.html index 01a7b1df952e4dca90835708dec3ffa2c5a86e19..5850cdcd49880062d41ca11f9bb425d544864d74 100644 --- a/wdfn-server/waterdata/templates/base_network.html +++ b/wdfn-server/waterdata/templates/base_network.html @@ -9,7 +9,7 @@ {% endblock %} {% block body %} - {% if request.user_agent.browser == 'msie' %} + {% if browser == 'IE' %} <script src="{{ 'scripts/wdfnviz.js' | asset_url }}"></script> {% else %} <script async src="{{ 'network-bundle.js' | asset_url }}"></script> diff --git a/wdfn-server/waterdata/templates/monitoring_location.html b/wdfn-server/waterdata/templates/monitoring_location.html index 6de0c0ffb2e6eff8548b17a8fe9fad3f8e6a51d6..417c7c9e8d700ffba928b43dcbc82662c64d4371 100644 --- a/wdfn-server/waterdata/templates/monitoring_location.html +++ b/wdfn-server/waterdata/templates/monitoring_location.html @@ -49,7 +49,7 @@ {% set body_id = 'monitoring-location' %} {% block body %} - {% if request.user_agent.browser == 'msie' %} + {% if browser == 'IE' %} <script src="{{ 'scripts/wdfnviz.js' | asset_url }}"></script> <script type="application/javascript"> document.addEventListener('DOMContentLoaded', function() { @@ -143,12 +143,12 @@ {{ components.QuestionTooltip('classic', 'View all current conditions values on the classic Water Data for the Nation interface.', True) }} </div> <p id="site-description">{{ components.Description(stations[0].site_no, location_with_values, parm_grp_summary) }} - {% if request.user_agent.browser == 'msie' %} + {% if browser == 'IE' %} {{ components.DescriptionInternetExplorerLinks(stations[0].site_no, location_with_values, parm_grp_summary) }} {% endif %} </p> </div> - {% if request.user_agent.browser == 'msie' %} + {% if browser == 'IE' %} <div id="static-graph-div"></div> <div class="usa-alert usa-alert--warning"> <div class="usa-alert__body"> @@ -160,7 +160,7 @@ </div> </div> {% endif %} - {% if request.user_agent.browser != 'msie' %} + {% if browser != 'IE' %} {{ components.TimeSeriesComponent(stations[0], default_parameter_code, iv_period_of_record, gw_period_of_record) }} {% if cameras %} {{ components.CameraComponent(cameras) }} diff --git a/wdfn-server/waterdata/views.py b/wdfn-server/waterdata/views.py index 51f9b4490965590015902e1a1d55d17b9a5a8c87..a3c955cc37e671960720373b0d3a1978f7e6b518 100644 --- a/wdfn-server/waterdata/views.py +++ b/wdfn-server/waterdata/views.py @@ -6,6 +6,8 @@ import datetime import json import smtplib +from ua_parser import user_agent_parser + from flask import abort, render_template, redirect, request, Markup, make_response, url_for from markdown import markdown @@ -177,8 +179,8 @@ async def monitoring_location(site_no): # Get the time zone for the location time_zone = time_zone_service.get_iana_time_zone(unique_site.get('dec_lat_va', ''), unique_site.get('dec_long_va', '')) - context = { + 'browser': user_agent_parser.Parse(request.user_agent.string)['user_agent']['family'], 'status_code': site_status, 'stations': site_data, 'location_with_values': location_with_values, @@ -301,6 +303,7 @@ def networks(network_cd): return render_template( 'networks.html', + browser=user_agent_parser.Parse(request.user_agent.string)['user_agent']['family'], http_code=http_code, network_cd=network_cd, collection=collection,