diff --git a/alertproviders/http_alert_provider.py b/alertproviders/http_alert_provider.py index c3e0515..afc3225 100644 --- a/alertproviders/http_alert_provider.py +++ b/alertproviders/http_alert_provider.py @@ -30,7 +30,8 @@ class HTTPAlertProvider(AlertProvider): thread.start() def stop(self): - self.poll_timer.cancel() + if self.poll_timer: + self.poll_timer.cancel() def poll(self): try: diff --git a/core/lookup_helper.py b/core/lookup_helper.py index 552b87d..d4779d3 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -96,10 +96,10 @@ class LookupHelper: try: logging.info("Downloading Clublog cty.xml...") response = self.CLUBLOG_CTY_XML_CACHE.get("https://cdn.clublog.org/cty.php?api=" + self.CLUBLOG_API_KEY, - headers=HTTP_HEADERS).raw - with gzip.GzipFile(fileobj=response) as uncompressed: + headers=HTTP_HEADERS) + open(self.CLUBLOG_XML_DOWNLOAD_LOCATION + ".gz", 'wb').write(response.content) + with gzip.open(self.CLUBLOG_XML_DOWNLOAD_LOCATION + ".gz", "rb") as uncompressed: file_content = uncompressed.read() - with open(self.CLUBLOG_XML_DOWNLOAD_LOCATION, "wb") as f: f.write(file_content) f.flush() diff --git a/data/alert.py b/data/alert.py index 8a7f474..b578137 100644 --- a/data/alert.py +++ b/data/alert.py @@ -96,7 +96,7 @@ class Alert: self.dx_itu_zone = lookup_helper.infer_itu_zone_from_callsign(self.dx_calls[0]) if self.dx_calls and self.dx_calls[0] and not self.dx_dxcc_id: self.dx_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.dx_calls[0]) - if self.dx_dxcc_id and not self.dx_flag: + if self.dx_dxcc_id and self.dx_dxcc_id in DXCC_FLAGS and not self.dx_flag: self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id] # DX operator details lookup, using QRZ.com. This should be the last resort compared to taking the data from diff --git a/data/spot.py b/data/spot.py index 07dae61..0cf8b34 100644 --- a/data/spot.py +++ b/data/spot.py @@ -124,7 +124,7 @@ class Spot: self.dx_itu_zone = lookup_helper.infer_itu_zone_from_callsign(self.dx_call) if self.dx_call and not self.dx_dxcc_id: self.dx_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.dx_call) - if self.dx_dxcc_id and DXCC_FLAGS[self.dx_dxcc_id] and not self.dx_flag: + if self.dx_dxcc_id and self.dx_dxcc_id in DXCC_FLAGS and not self.dx_flag: self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id] # Clean up spotter call if it has an SSID or -# from RBN @@ -138,7 +138,7 @@ class Spot: self.de_continent = lookup_helper.infer_continent_from_callsign(self.de_call) if self.de_call and not self.de_dxcc_id: self.de_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.de_call) - if self.de_dxcc_id and not self.de_flag: + if self.de_dxcc_id and self.de_dxcc_id in DXCC_FLAGS and not self.de_flag: self.de_flag = DXCC_FLAGS[self.de_dxcc_id] # Band from frequency diff --git a/spotproviders/http_spot_provider.py b/spotproviders/http_spot_provider.py index 3b40293..1a3b704 100644 --- a/spotproviders/http_spot_provider.py +++ b/spotproviders/http_spot_provider.py @@ -30,7 +30,8 @@ class HTTPSpotProvider(SpotProvider): thread.start() def stop(self): - self.poll_timer.cancel() + if self.poll_timer: + self.poll_timer.cancel() def poll(self): try: diff --git a/views/webpage_spots.tpl b/views/webpage_spots.tpl index 2fb2dc3..c12e669 100644 --- a/views/webpage_spots.tpl +++ b/views/webpage_spots.tpl @@ -1,13 +1,5 @@ % rebase('webpage_base.tpl') - -
- -
-

- +

@@ -193,7 +185,7 @@
-
+
Add a Spot @@ -205,7 +197,39 @@
-

Coming soon!

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 2a79b7b..8ed78d8 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -337,6 +337,64 @@ function userGridUpdated() { saveSettings(); } +// Method called to add a spot to the server +function addSpot() { + try { + var dx = $("#add-spot-dx-call").val().toUpperCase(); + var freqStr = $("#add-spot-freq").val(); + var mode = $("#add-spot-mode").val().toUpperCase(); + var comment = $("#add-spot-comment").val(); + var de = $("#add-spot-de-call").val().toUpperCase(); + + var spot = {} + if (dx != "") { + spot["dx_call"] = dx; + } else { + showAddSpotError("A DX callsign is required in order to spot."); + return; + } + if (freqStr != "") { + spot["freq"] = parseFloat(freqStr) * 1000; + } else { + showAddSpotError("A frequency is required in order to spot."); + return; + } + if (mode != "") { + spot["mode"] = mode; + } + if (comment != "") { + spot["comment"] = comment; + } + if (de != "") { + spot["de_call"] = de; + } + spot["time"] = moment.utc().valueOf() / 1000.0; + + $.ajax("/api/v1/spot", { + data : JSON.stringify(spot), + contentType : 'application/json', + type : 'POST', + timeout: 10000, + success: async function (result) { + $("#post-spot-result-good").html(""); + setTimeout(() => $("#post-spot-result-good").hide(), 2000); + loadSpots(); + }, + error: function (result) { + showAddSpotError(result.responseText); + } + }); + } catch (error) { + showAddSpotError(error); + } + return false; +} + +// Show an "add spot" error. +function showAddSpotError(text) { + $("#post-spot-result-bad").html(""); +} + // React to toggling/closing panels function toggleFiltersPanel() { // If we are going to show the filters panel, hide the display and add spot panels