From 237cdaa09158ec305fbcf7110adf7f3980a9f4c3 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 5 Sep 2026 10:14:37 +0100 Subject: [PATCH] Fix icon and ref_type disappearing from SIG Ref lookups --- core/sig_lookup_helper.py | 19 +++++++++---------- 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, 24 insertions(+), 25 deletions(-) diff --git a/core/sig_lookup_helper.py b/core/sig_lookup_helper.py index 92ca542..d3649e3 100644 --- a/core/sig_lookup_helper.py +++ b/core/sig_lookup_helper.py @@ -29,14 +29,11 @@ def get_sig_ref_info(sig_name, ref_id): # Prepare the object to be returned sig_ref = SIGRef(sig=sig_name, id=ref_id) - # We can always get the reference type and the icon from the SIG itself, if the reference data doesn't already - # contain it. If the sig ref already has this data, it should be used for preference. + # We can always get the reference type and the icon from the SIG itself for sig in SIGS: if sig.name.upper() == sig_name.upper(): - if not sig_ref.ref_type: - sig_ref.ref_type = sig.ref_type - if not sig_ref.icon: - sig_ref.icon = sig.icon + sig_ref.ref_type = sig.ref_type + sig_ref.icon = sig.icon try: ### FUDGES ### @@ -45,7 +42,7 @@ def get_sig_ref_info(sig_name, ref_id): # activators add leading zeros. We also need to normalise "DME 01234" to "DME-01234" to match what's in our # database. if sig_name.upper() == "DME": - match = re.match(r"DME[\- ]\d{3,5}", ref_id, re.IGNORECASE) + match = re.match(r"DME[\- ](\d{3,5})", ref_id, re.IGNORECASE) number = match.group(1) return f"DME-{number.zfill(5)}" @@ -113,12 +110,14 @@ def get_sig_ref_info(sig_name, ref_id): ### ACTUAL LOOKUP ### # - # OK, this is something we have to look up. Now check to see if our data store contains reference data and use - # that. + # OK, this is something we have to look up. Now check to see if our data store contains reference data and if + # so, copy the data into the sig_ref object key = f"{sig_name}:{ref_id}" lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None if lookup_data: - return lookup_data + for key, value in lookup_data.__dict__.items(): + if value is not None and sig_ref.__dict__.get(key) is None: + sig_ref.__dict__[key] = value else: # Maybe a super new reference we don't know about yet, but more likely a typo or a test reference, diff --git a/templates/add_spot.html b/templates/add_spot.html index c9a69b6..0f806e3 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 78f0126..32532ad 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -81,7 +81,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 86e9496..be264d0 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index b213f7d..eeeac64 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 6f698ed..69da9f6 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index c57d5b7..c16f763 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 25da752..1471da7 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index a80e593..c3ca065 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +