Fix a bug in PNP spot handling where an exception would be thrown if an activity had a location name but not a reference ID.

This commit is contained in:
Ian Renton
2026-09-20 10:10:39 +01:00
parent 2df7ecf4b5
commit d33259d619
9 changed files with 36 additions and 21 deletions
+21 -6
View File
@@ -68,21 +68,33 @@ class ParksNPeaks(HTTPSpotProvider):
# Record activity information # Record activity information
activity = source_spot["actClass"].upper() activity = source_spot["actClass"].upper()
ref_id = source_spot["actSiteID"] ref_id = source_spot["actSiteID"]
if activity: if activity:
spot.sig = activity spot.sig = activity
activity_refs = []
if ref_id: if ref_id:
activity_refs = [ activity_refs = [
ActivityRef( ActivityRef(
id=source_spot["actSiteID"], id=ref_id,
sig=activity, sig=activity,
# Free text location is not present in all spots, so only add it if it's set
name=source_spot["actLocation"]
if "actLocation" in source_spot and source_spot["actLocation"] != ""
else None,
) )
] ]
spot.sig_refs = activity_refs spot.sig_refs = activity_refs
# Free text location is not present in all spots, so only add it if it's set else:
if "actLocation" in source_spot and source_spot["actLocation"] != "": # If no actSiteID is set, e.g. because actClass is "QRP", sometimes we still have an actLocation
activity_refs[0].name = source_spot["actLocation"] # which is free text like "SOTA G/SC-001". If we have that, and not a normal comment field, use
# that location as the comment field so the information doesn't get lost.
if (
"actLocation" in source_spot
and source_spot["actLocation"] != ""
and ("actComments" not in source_spot or source_spot["actComments"] == "")
):
spot.comment = source_spot["actLocation"]
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before # Log a warning for the developer if PnP gives us an unknown programme we've never seen before
if activity not in [ if activity not in [
@@ -95,8 +107,11 @@ class ParksNPeaks(HTTPSpotProvider):
ActivityName.KRMNPA, ActivityName.KRMNPA,
ActivityName.SANPCPA, ActivityName.SANPCPA,
ActivityName.LLOTA, ActivityName.LLOTA,
ActivityName.QRP,
]: ]:
logger.warning(f"PNP spot found with activity {activity}, developer needs to add support for this!") logger.warning(
f"PNP spot found with activity {activity}, developer needs to add support for this!"
)
# Add new spot to the list # Add new spot to the list
new_spots.append(spot) new_spots.append(spot)
+1 -1
View File
@@ -77,7 +77,7 @@
</div> </div>
<script src="/static/js/add-spot.js?v=1789894090"></script> <script src="/static/js/add-spot.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-add-spot").addClass("active"); $("#nav-link-add-spot").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -85,7 +85,7 @@
</div> </div>
<script src="/static/js/alerts.js?v=1789894090"></script> <script src="/static/js/alerts.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-alerts").addClass("active"); $("#nav-link-alerts").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -76,8 +76,8 @@
</div> </div>
<script src="/static/js/spotsbandsandmap.js?v=1789894090"></script> <script src="/static/js/spotsbandsandmap.js?v=1789895439"></script>
<script src="/static/js/bands.js?v=1789894090"></script> <script src="/static/js/bands.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-bands").addClass("active"); $("#nav-link-bands").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+5 -5
View File
@@ -1,6 +1,6 @@
{% extends "skeleton.html" %} {% extends "skeleton.html" %}
{% block head_extra %} {% block head_extra %}
<link rel="stylesheet" href="/static/css/style.css?v=1789894090" type="text/css"> <link rel="stylesheet" href="/static/css/style.css?v=1789895439" type="text/css">
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet"> <link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet"> <link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet"> <link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
@@ -16,10 +16,10 @@
window.fetchEventSource = fetchEventSource; window.fetchEventSource = fetchEventSource;
</script> </script>
<script src="/static/js/utils.js?v=1789894090"></script> <script src="/static/js/utils.js?v=1789895439"></script>
<script src="/static/js/ui-ham.js?v=1789894090"></script> <script src="/static/js/ui-ham.js?v=1789895439"></script>
<script src="/static/js/geo.js?v=1789894090"></script> <script src="/static/js/geo.js?v=1789895439"></script>
<script src="/static/js/common.js?v=1789894090"></script> <script src="/static/js/common.js?v=1789895439"></script>
{% end %} {% end %}
{% block body %} {% block body %}
<div class="container"> <div class="container">
+1 -1
View File
@@ -284,7 +284,7 @@
</div> </div>
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script> <script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
<script src="/static/js/conditions.js?v=1789894090"></script> <script src="/static/js/conditions.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active"); $("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -113,8 +113,8 @@
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
</script> </script>
<script src="/static/js/spotsbandsandmap.js?v=1789894090"></script> <script src="/static/js/spotsbandsandmap.js?v=1789895439"></script>
<script src="/static/js/map.js?v=1789894090"></script> <script src="/static/js/map.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-map").addClass("active"); $("#nav-link-map").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -125,8 +125,8 @@
</div> </div>
<script src="/static/js/spotsbandsandmap.js?v=1789894090"></script> <script src="/static/js/spotsbandsandmap.js?v=1789895439"></script>
<script src="/static/js/spots.js?v=1789894090"></script> <script src="/static/js/spots.js?v=1789895439"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-spots").addClass("active"); $("#nav-link-spots").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -96,7 +96,7 @@
</div> </div>
</div> </div>
<script src="/static/js/status.js?v=1789894090"></script> <script src="/static/js/status.js?v=1789895439"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#nav-link-status").addClass("active"); $("#nav-link-status").addClass("active");