Fix order in which grids are parsed out of comments

This commit is contained in:
Ian Renton
2026-09-20 19:01:48 +01:00
parent 6f96e0ede1
commit 9272766ffb
9 changed files with 34 additions and 34 deletions
+19 -19
View File
@@ -380,11 +380,19 @@ class Spot:
self.propagation_mode = mode_tag self.propagation_mode = mode_tag
logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}") logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}")
# Set activities based on propagation mode # Parse "de_grid -> dx_grid" structures from the comment
if self.propagation_mode == "Satellite" and not self.sig: if self.comment:
self.sig = ActivityName.SATELLITE grid_match = re.search(
if self.propagation_mode == "Earth-Moon-Earth" and not self.sig: r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\s*->\s*([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b",
self.sig = ActivityName.EME self.comment,
)
if grid_match:
# regex matches, so extract grids:
if not self.de_grid:
self.de_grid = grid_match.group(1).upper()
if not self.dx_grid:
self.dx_grid = grid_match.group(2).upper()
self.dx_location_source = LocationSourceForSpot.GRID
# Parse 6-digit grid structures from the comment if the frequency is VHF or above, as it's common to see # Parse 6-digit grid structures from the comment if the frequency is VHF or above, as it's common to see
# VHF+ operators spotted with their grid # VHF+ operators spotted with their grid
@@ -397,6 +405,12 @@ class Spot:
self.dx_grid = grid_match.group(1).upper() self.dx_grid = grid_match.group(1).upper()
self.dx_location_source = LocationSourceForSpot.GRID self.dx_location_source = LocationSourceForSpot.GRID
# Set activities based on propagation mode
if self.propagation_mode == "Satellite" and not self.sig:
self.sig = ActivityName.SATELLITE
if self.propagation_mode == "Earth-Moon-Earth" and not self.sig:
self.sig = ActivityName.EME
# Set activities based on the DX callsign suffix # Set activities based on the DX callsign suffix
if self.dx_call and not self.sig: if self.dx_call and not self.sig:
if self.dx_call.upper().endswith(ActivityName.AERONAUTICAL_MOBILE): if self.dx_call.upper().endswith(ActivityName.AERONAUTICAL_MOBILE):
@@ -420,20 +434,6 @@ class Spot:
self.sig = ActivityName.DXPEDITION self.sig = ActivityName.DXPEDITION
break break
# Parse "de_grid -> dx_grid" structures from the comment
if self.comment:
grid_match = re.search(
r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\s*->\s*([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b",
self.comment,
)
if grid_match:
# regex matches, so extract grids:
if not self.dx_grid:
self.dx_grid = grid_match.group(1).upper()
self.dx_location_source = LocationSourceForSpot.GRID
if not self.de_grid:
self.de_grid = grid_match.group(2).upper()
# DX Grid to lat/lon and vice versa in case one is missing # DX Grid to lat/lon and vice versa in case one is missing
if self.dx_grid and (not self.dx_latitude or not self.dx_longitude): if self.dx_grid and (not self.dx_latitude or not self.dx_longitude):
try: try:
+1 -1
View File
@@ -77,7 +77,7 @@
</div> </div>
<script src="/static/js/add-spot.js?v=1789896773"></script> <script src="/static/js/add-spot.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/alerts.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
<script src="/static/js/bands.js?v=1789896773"></script> <script src="/static/js/bands.js?v=1789927308"></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=1789896773" type="text/css"> <link rel="stylesheet" href="/static/css/style.css?v=1789927308" 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=1789896773"></script> <script src="/static/js/utils.js?v=1789927308"></script>
<script src="/static/js/ui-ham.js?v=1789896773"></script> <script src="/static/js/ui-ham.js?v=1789927308"></script>
<script src="/static/js/geo.js?v=1789896773"></script> <script src="/static/js/geo.js?v=1789927308"></script>
<script src="/static/js/common.js?v=1789896773"></script> <script src="/static/js/common.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/conditions.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
<script src="/static/js/map.js?v=1789896773"></script> <script src="/static/js/map.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
<script src="/static/js/spots.js?v=1789896773"></script> <script src="/static/js/spots.js?v=1789927308"></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=1789896773"></script> <script src="/static/js/status.js?v=1789927308"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#nav-link-status").addClass("active"); $("#nav-link-status").addClass("active");