From d33259d619f72ac1b2bede24c65957f827710731 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 20 Sep 2026 10:10:39 +0100 Subject: [PATCH] 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. --- providers/spot/parksnpeaks.py | 27 +++++++++++++++++++++------ templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 36 insertions(+), 21 deletions(-) diff --git a/providers/spot/parksnpeaks.py b/providers/spot/parksnpeaks.py index 45b0105..65e70da 100644 --- a/providers/spot/parksnpeaks.py +++ b/providers/spot/parksnpeaks.py @@ -68,21 +68,33 @@ class ParksNPeaks(HTTPSpotProvider): # Record activity information activity = source_spot["actClass"].upper() ref_id = source_spot["actSiteID"] + if activity: spot.sig = activity - activity_refs = [] + if ref_id: activity_refs = [ ActivityRef( - id=source_spot["actSiteID"], + id=ref_id, 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 - # Free text location is not present in all spots, so only add it if it's set - if "actLocation" in source_spot and source_spot["actLocation"] != "": - activity_refs[0].name = source_spot["actLocation"] + else: + # If no actSiteID is set, e.g. because actClass is "QRP", sometimes we still have an 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 if activity not in [ @@ -95,8 +107,11 @@ class ParksNPeaks(HTTPSpotProvider): ActivityName.KRMNPA, ActivityName.SANPCPA, 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 new_spots.append(spot) diff --git a/templates/add_spot.html b/templates/add_spot.html index 0de4bfe..9f0f32b 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 7baf852..7e778dc 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -85,7 +85,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 0a37e54..d21ba65 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 099c30d..448d46c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 61ae73b..c0415c8 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 74af3f0..979aef5 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index bba1ff0..900c8dc 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -125,8 +125,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index d256a86..b965ef5 100644 --- a/templates/status.html +++ b/templates/status.html @@ -96,7 +96,7 @@ - +