Allow adding the DX grid when spotting #71

This commit is contained in:
Ian Renton
2025-11-01 11:11:33 +00:00
parent 57d950c1ca
commit 471c487132
3 changed files with 21 additions and 2 deletions

View File

@@ -165,9 +165,16 @@ class WebServer:
response.status = 422
return json.dumps("Error - Frequency of " + str(spot.freq / 1000.0) + "kHz is not in a known band.", default=serialize_everything)
# Reject if grid formatting incorrect
if spot.dx_grid and not re.match(r"^([A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}|[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}|[A-R]{2}[0-9]{2}[A-X]{2}|[A-R]{2}[0-9]{2})$", spot.dx_grid.upper()):
response.content_type = 'application/json'
response.status = 422
return json.dumps("Error - '" + spot.dx_grid + "' does not look like a valid Maidenhead grid.", default=serialize_everything)
# infer missing data, and add it to our database.
spot.source = "API"
spot.icon = "desktop"
if not spot.sig:
spot.icon = "desktop"
spot.infer_missing()
self.spots.add(spot.id, spot, expire=MAX_SPOT_AGE)