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,8 +165,15 @@ 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"
if not spot.sig:
spot.icon = "desktop"
spot.infer_missing()
self.spots.add(spot.id, spot, expire=MAX_SPOT_AGE)

View File

@@ -31,7 +31,11 @@
<input type="text" class="form-control" id="mode" placeholder="SSB" style="max-width: 6em;">
</div>
<div class="col-auto">
<label for="comment" class="form-label">Comment</label>
<label for="dx-grid" class="form-label">DX Grid (Optional)</label>
<input type="text" class="form-control" id="dx-grid" placeholder="AA00aa" style="max-width: 8em;">
</div>
<div class="col-auto">
<label for="comment" class="form-label">Comment (Optional)</label>
<input type="text" class="form-control" id="comment" placeholder="59 TNX QSO 73" style="max-width: 12em;">
</div>
<div class="col-auto">

View File

@@ -8,6 +8,7 @@ function addSpot() {
var dx = $("#dx-call").val().toUpperCase();
var freqStr = $("#freq").val();
var mode = $("#mode").val().toUpperCase();
var dxGrid = $("#dx-grid").val();
var comment = $("#comment").val();
var de = $("#de-call").val().toUpperCase();
@@ -27,11 +28,17 @@ function addSpot() {
if (mode != "") {
spot["mode"] = mode;
}
if (dxGrid != "") {
spot["dx_grid"] = dxGrid;
}
if (comment != "") {
spot["comment"] = comment;
}
if (de != "") {
spot["de_call"] = de;
} else {
showAddSpotError("A spotter callsign is required in order to spot.");
return;
}
spot["time"] = moment.utc().valueOf() / 1000.0;
@@ -42,6 +49,7 @@ function addSpot() {
timeout: 10000,
success: async function (result) {
$("#result-good").html("<button type='button' class='btn btn-success' style='margin-top: 2em;'><i class='fa-solid fa-check'></i> OK</button>");
$("#result-bad").html("");
setTimeout(() => {
$("#result-good").hide();
window.location.replace("/");