From efec8e220ec96ed3ce396907d490e76e926c7e30 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 14 Aug 2026 17:59:15 +0100 Subject: [PATCH] Oops, "type" was a bad choice of field name --- data/sig_ref.py | 2 +- providers/sigrefdata/arlhs.py | 2 +- providers/sigrefdata/dme.py | 2 +- providers/sigrefdata/gma.py | 2 +- providers/sigrefdata/illw.py | 2 +- providers/sigrefdata/iota.py | 2 +- providers/sigrefdata/llota.py | 2 +- providers/sigrefdata/mota.py | 2 +- providers/sigrefdata/pnp_kml_sig_ref_data_provider.py | 2 +- providers/sigrefdata/pota.py | 2 +- providers/sigrefdata/siota.py | 2 +- providers/sigrefdata/sota.py | 2 +- providers/sigrefdata/toilets.py | 2 +- providers/sigrefdata/towers.py | 2 +- providers/sigrefdata/wca.py | 2 +- providers/sigrefdata/wota.py | 2 +- providers/sigrefdata/wwbota.py | 2 +- providers/sigrefdata/wwff.py | 2 +- providers/sigrefdata/zlota.py | 2 +- server/handlers/api/alerts.py | 11 +++++++++++ static/apidocs/openapi.yml | 4 ++-- 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 +- 29 files changed, 47 insertions(+), 36 deletions(-) diff --git a/data/sig_ref.py b/data/sig_ref.py index 949f580..26ea482 100644 --- a/data/sig_ref.py +++ b/data/sig_ref.py @@ -13,7 +13,7 @@ class SIGRef: # Name of the reference, e.g. "Null Country Park", if known. name: str | None = None # Type of the reference, e.g. "Park", if known. - type: str | None = None + ref_type: str | None = None # URL to look up more information about the reference, if known. url: str | None = None # Latitude of the reference, in degrees, if known. diff --git a/providers/sigrefdata/arlhs.py b/providers/sigrefdata/arlhs.py index 871932b..f61e8ec 100644 --- a/providers/sigrefdata/arlhs.py +++ b/providers/sigrefdata/arlhs.py @@ -21,7 +21,7 @@ class ARLHS(FileDownloadSIGRefDataProvider): if "ARLHS" in row and row["ARLHS"] != "": ref_id = row["ARLHS"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None, - type="Lighthouse", + ref_type="Lighthouse", url="https://www.cqgma.org/zinfo.php?ref=" + ref_id, latitude=float(row["Latitude"]) if "Latitude" in row and row[ "Latitude"] != "" else None, diff --git a/providers/sigrefdata/dme.py b/providers/sigrefdata/dme.py index a175dc0..3756167 100644 --- a/providers/sigrefdata/dme.py +++ b/providers/sigrefdata/dme.py @@ -27,7 +27,7 @@ class DME(LocalFileSIGRefDataProvider): "LONGITUD_ETRS89_REGCAN95") else None ref = SIGRef(sig=self.SIG, id=ref_id, - type="Town", + ref_type="Town", name=row["NOMBRE_ACTUAL"] + ", " + row["PROVINCIA"], latitude=latitude, longitude=longitude) diff --git a/providers/sigrefdata/gma.py b/providers/sigrefdata/gma.py index 8bd3067..2d817a5 100644 --- a/providers/sigrefdata/gma.py +++ b/providers/sigrefdata/gma.py @@ -20,7 +20,7 @@ class GMA(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()[1:]): ref_id = row["Reference"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None, - type="Summit", + ref_type="Summit", url="https://www.cqgma.org/zinfo.php?ref=" + ref_id, latitude=float(row["Latitude"]) if "Latitude" in row and row[ "Latitude"] != "" else None, diff --git a/providers/sigrefdata/illw.py b/providers/sigrefdata/illw.py index a5fef30..3a182d0 100644 --- a/providers/sigrefdata/illw.py +++ b/providers/sigrefdata/illw.py @@ -21,7 +21,7 @@ class ILLW(FileDownloadSIGRefDataProvider): if "ILLW" in row and row["ILLW"] != "": ref_id = row["ILLW"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None, - type="Lighthouse", + ref_type="Lighthouse", url="https://www.cqgma.org/zinfo.php?ref=" + ref_id, latitude=float(row["Latitude"]) if "Latitude" in row and row[ "Latitude"] != "" else None, diff --git a/providers/sigrefdata/iota.py b/providers/sigrefdata/iota.py index eeef47e..d9bcda9 100644 --- a/providers/sigrefdata/iota.py +++ b/providers/sigrefdata/iota.py @@ -32,7 +32,7 @@ class IOTA(FileDownloadSIGRefDataProvider): logging.debug(f"Error converting lat/lon to locator for an IOTA reference %f %f", latitude, longitude) new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=ref["name"], - type="Island", grid=grid, latitude=latitude, longitude=longitude)) + ref_type="Island", grid=grid, latitude=latitude, longitude=longitude)) # Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest # of the data in this case diff --git a/providers/sigrefdata/llota.py b/providers/sigrefdata/llota.py index d0a4865..b274bf4 100644 --- a/providers/sigrefdata/llota.py +++ b/providers/sigrefdata/llota.py @@ -26,7 +26,7 @@ class LLOTA(FileDownloadSIGRefDataProvider): ll = locator_to_latlong(grid) new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=str(ref["name"]), - type="Lake", + ref_type="Lake", url="https://llota.app/list/ref/" + ref_id, grid=grid, latitude=ll[0], diff --git a/providers/sigrefdata/mota.py b/providers/sigrefdata/mota.py index 1b0d6d8..364ce7c 100644 --- a/providers/sigrefdata/mota.py +++ b/providers/sigrefdata/mota.py @@ -20,7 +20,7 @@ class MOTA(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()[1:]): ref_id = row["Reference"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None, - type="Mill", + ref_type="Mill", url="https://www.cqgma.org/zinfo.php?ref=" + ref_id, latitude=float(row["Latitude"]) if "Latitude" in row and row[ "Latitude"] != "" else None, diff --git a/providers/sigrefdata/pnp_kml_sig_ref_data_provider.py b/providers/sigrefdata/pnp_kml_sig_ref_data_provider.py index 3ef7130..1298759 100644 --- a/providers/sigrefdata/pnp_kml_sig_ref_data_provider.py +++ b/providers/sigrefdata/pnp_kml_sig_ref_data_provider.py @@ -36,7 +36,7 @@ class ParksNPeaksKMLSIGRefDataProvider(FileDownloadSIGRefDataProvider): longitude, latitude = placemark.geometry.x, placemark.geometry.y ref = SIGRef(sig=self.sig_name, id=ref_id, name=placemark.name, - type="Park", + ref_type="Park", url="https://parksnpeaks.org/getPark.php?actPark=" + ref_id, latitude=latitude, longitude=longitude) diff --git a/providers/sigrefdata/pota.py b/providers/sigrefdata/pota.py index 7991e5b..656cc82 100644 --- a/providers/sigrefdata/pota.py +++ b/providers/sigrefdata/pota.py @@ -20,7 +20,7 @@ class POTA(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()): ref_id = row["reference"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["name"] if "name" in row else None, - type="Park", + ref_type="Park", url="https://pota.app/#/park/" + ref_id, grid=row["grid"] if "grid" in row else None, latitude=float(row["latitude"]) if "latitude" in row and row[ diff --git a/providers/sigrefdata/siota.py b/providers/sigrefdata/siota.py index 8a2cf1f..56513b4 100644 --- a/providers/sigrefdata/siota.py +++ b/providers/sigrefdata/siota.py @@ -20,7 +20,7 @@ class SIOTA(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()): ref_id = row["SILO_CODE"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["NAME"] if "NAME" in row else None, - type="Silo", + ref_type="Silo", grid=row["LOCATOR"] if "LOCATOR" in row else None, latitude=float(row["LAT"]) if "LAT" in row else None, longitude=float(row["LNG"]) if "LNG" in row else None)) diff --git a/providers/sigrefdata/sota.py b/providers/sigrefdata/sota.py index ea40a0b..8a04bec 100644 --- a/providers/sigrefdata/sota.py +++ b/providers/sigrefdata/sota.py @@ -25,7 +25,7 @@ class SOTA(FileDownloadSIGRefDataProvider): longitude = float(row["Longitude"]) if "Longitude" in row and row["Longitude"] != "" else None altitude = float(row["AltM"]) if "AltM" in row and row["AltM"] != "" else None ref = SIGRef(sig=self.SIG, id=ref_id, name=row["SummitName"] if "SummitName" in row else None, - type="Summit", + ref_type="Summit", url="https://www.sotadata.org.uk/en/summit/" + ref_id, latitude=latitude, longitude=longitude, diff --git a/providers/sigrefdata/toilets.py b/providers/sigrefdata/toilets.py index dc35139..2929677 100644 --- a/providers/sigrefdata/toilets.py +++ b/providers/sigrefdata/toilets.py @@ -19,7 +19,7 @@ class Toilets(LocalFileSIGRefDataProvider): csv_data = _f.read() dr = csv.DictReader(csv_data.splitlines()) for row in dr: - new_data.append(SIGRef(sig=self.SIG, id=row["ref"], name=row["ref"], type="Toilet", + new_data.append(SIGRef(sig=self.SIG, id=row["ref"], name=row["ref"], ref_type="Toilet", latitude=float(row["lat"]), longitude=float(row["lon"]))) # Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest diff --git a/providers/sigrefdata/towers.py b/providers/sigrefdata/towers.py index 5b309c3..493081e 100644 --- a/providers/sigrefdata/towers.py +++ b/providers/sigrefdata/towers.py @@ -20,7 +20,7 @@ class Towers(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines(), delimiter=";"): ref_id = row["Ref"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Nazev"] if "Nazev" in row else None, - type="Tower", + ref_type="Tower", url="https://wwtota.com/seznam/karta_rozhledny.php?ref=" + ref_id, grid=row["Lokator"] if "Lokator" in row and row["Lokator"] != "" else None, latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None, diff --git a/providers/sigrefdata/wca.py b/providers/sigrefdata/wca.py index 97e1cd3..1bba095 100644 --- a/providers/sigrefdata/wca.py +++ b/providers/sigrefdata/wca.py @@ -37,7 +37,7 @@ class WCA(FileDownloadSIGRefDataProvider): logging.debug(f"Encountered dodgy formatting in WCA CSV, skipping location data for %s", ref_id) new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["CLEAN NAME"] if "CLEAN NAME" in row else None, - type="Castle", + ref_type="Castle", url="https://www.cqgma.org/zinfo.php?ref=" + ref_id, latitude=latitude, longitude=longitude, diff --git a/providers/sigrefdata/wota.py b/providers/sigrefdata/wota.py index 092ae47..f713136 100644 --- a/providers/sigrefdata/wota.py +++ b/providers/sigrefdata/wota.py @@ -26,7 +26,7 @@ class WOTA(FileDownloadSIGRefDataProvider): url = "https://www.wota.org.uk/MM_LDO-" + str(number + 214) new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=feature["properties"]["title"], url=url, - type="Summit", + ref_type="Summit", grid=feature["properties"]["qthLocator"], latitude=feature["geometry"]["coordinates"][1], longitude=feature["geometry"]["coordinates"][0], diff --git a/providers/sigrefdata/wwbota.py b/providers/sigrefdata/wwbota.py index 1cdf828..63fa00c 100644 --- a/providers/sigrefdata/wwbota.py +++ b/providers/sigrefdata/wwbota.py @@ -20,7 +20,7 @@ class WWBOTA(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()): ref_id = row["Reference"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None, - type="Bunker", + ref_type="Bunker", url="https://bunkerwiki.org/?s=" + ref_id if ref_id.startswith("B/G") else None, grid=row["Locator"] if "Locator" in row and row["Locator"] != "" else None, latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None, diff --git a/providers/sigrefdata/wwff.py b/providers/sigrefdata/wwff.py index fc5c840..bf72f44 100644 --- a/providers/sigrefdata/wwff.py +++ b/providers/sigrefdata/wwff.py @@ -20,7 +20,7 @@ class WWFF(FileDownloadSIGRefDataProvider): for row in csv.DictReader(http_response.content.decode("utf-8-sig").splitlines()): ref_id = row["reference"] new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["name"] if "name" in row else None, - type="Park", + ref_type="Park", url="https://wwff.co/directory/?showRef=" + ref_id, grid=row["iaruLocator"] if "iaruLocator" in row and row[ "iaruLocator"] != "-" else None, diff --git a/providers/sigrefdata/zlota.py b/providers/sigrefdata/zlota.py index 0e8c085..be6461f 100644 --- a/providers/sigrefdata/zlota.py +++ b/providers/sigrefdata/zlota.py @@ -26,7 +26,7 @@ class ZLOTA(FileDownloadSIGRefDataProvider): longitude = ref["longitude"] new_ref = SIGRef(sig=self.SIG, id=ref_id, name=ref["name"], - type=ref["asset_type"].title, + ref_type=ref["asset_type"].title, url="https://ontheair.nz/assets/" + ref_id.replace("/", "_"), latitude=latitude, longitude=longitude) diff --git a/server/handlers/api/alerts.py b/server/handlers/api/alerts.py index 3000153..c650d4a 100644 --- a/server/handlers/api/alerts.py +++ b/server/handlers/api/alerts.py @@ -1,4 +1,5 @@ import copy +import inspect import logging from datetime import datetime from typing import Any @@ -52,6 +53,7 @@ class APIAlertsHandler(tornado.web.RequestHandler): data = get_alert_list_with_filters(self._alerts, query_params) if credentials: data = self._enrich(data, credentials) + find_bad_values(data) self.write(safe_json_dumps(data)) self.set_status(200) except ValueError as e: @@ -64,6 +66,15 @@ class APIAlertsHandler(tornado.web.RequestHandler): self.set_header("Cache-Control", "no-store") self.set_header("Content-Type", "application/json") +def find_bad_values(obj, path="data"): + if isinstance(obj, dict): + for k, v in obj.items(): + find_bad_values(v, f"{path}[{k!r}]") + elif isinstance(obj, (list, tuple)): + for i, v in enumerate(obj): + find_bad_values(v, f"{path}[{i}]") + elif inspect.isbuiltin(obj) or inspect.ismethod(obj) or inspect.isfunction(obj): + print(f"Found bad value at {path}: {obj!r}") class APIAlertsStreamHandler(tornado_eventsource.handler.EventSourceHandler): """API request handler for /api/v2/alerts/stream""" diff --git a/static/apidocs/openapi.yml b/static/apidocs/openapi.yml index a7dffdf..d7be310 100644 --- a/static/apidocs/openapi.yml +++ b/static/apidocs/openapi.yml @@ -26,7 +26,7 @@ info: * GET `/options` now returns `spot_submit_providers`, a map of SIG names to the names of providers that support upstream spot submission for that SIG. (This allows clients to present the user with options of where a new spot can be sent to.) * Added `sig_ref_data_providers`, `static_data_providers` and `callsign_data_providers` to `/status` response * Added `callsign_data_providers` and `spot_providers_enabled_by_default` to `/options` response - * SIG Refs now have `type` and `altitude` parameters + * SIG Refs now have `ref_type` and `altitude` parameters #### Upgrading a client from v1 to v2 API endpoints @@ -997,7 +997,7 @@ components: type: string description: SIG reference name example: Null Country Park - type: + ref_type: type: string description: SIG reference type example: Park diff --git a/templates/add_spot.html b/templates/add_spot.html index 45ce2c5..5896820 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 4743595..803ea6c 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -82,7 +82,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index ec13c86..5898c8e 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -79,8 +79,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 454f131..e1ba519 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -10,10 +10,10 @@ - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index c5c23e0..4f6978c 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 8255225..828ab10 100644 --- a/templates/map.html +++ b/templates/map.html @@ -112,8 +112,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index 137aaf7..64dd950 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -118,8 +118,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 04809c6..9c86561 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +