mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Now that SIGs are rebranded as Activities, we can merge DXpedition and Contest into that without it being too weird, and get rid of AlertType #147
This commit is contained in:
+5
-12
@@ -7,8 +7,9 @@ from datetime import datetime, timedelta
|
||||
import pytz
|
||||
|
||||
from core.activity_lookup_helper import populate_missing_activity_ref_info
|
||||
from core.activity_utils import get_icon_for_activity
|
||||
from core.call_lookup_helper import get_call_info
|
||||
from core.enums import AlertType, Continent
|
||||
from core.enums import Continent
|
||||
from core.utils import get_flag_for_dxcc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -54,8 +55,6 @@ class Alert:
|
||||
end_time_iso: str | None = None
|
||||
# Comment made by the alerter, if any
|
||||
comment: str | None = None
|
||||
# The type of alert this is: xOTA, DXpedition, or Contest.
|
||||
alert_type: AlertType | None = None
|
||||
# A URL link to more information, if any
|
||||
url: str | None = None
|
||||
|
||||
@@ -153,16 +152,10 @@ class Alert:
|
||||
if self.dx_calls and not self.dx_names:
|
||||
self.dx_names = [get_call_info(c, credentials).name for c in self.dx_calls]
|
||||
|
||||
# Icon for the spot should be the icon of the first activity ref if present, otherwise a radio tower
|
||||
# Icon for the alert should be the icon of its activity if known, otherwise a radio tower
|
||||
self.icon = "fa-tower-cell"
|
||||
if self.alert_type == AlertType.DXPEDITION:
|
||||
self.icon = "fa-globe-africa"
|
||||
elif self.alert_type == AlertType.CONTEST:
|
||||
self.icon = "fa-trophy"
|
||||
elif self.alert_type == AlertType.SATELLITE:
|
||||
self.icon = "fa-satellite"
|
||||
elif self.sig_refs and self.sig_refs[0].icon:
|
||||
self.icon = self.sig_refs[0].icon
|
||||
if self.sig and (activity_icon := get_icon_for_activity(self.sig)):
|
||||
self.icon = activity_icon
|
||||
|
||||
except Exception:
|
||||
logger.exception("Exception while inferring missing data from spot")
|
||||
|
||||
+8
-13
@@ -13,6 +13,7 @@ from core.activity_lookup_helper import populate_missing_activity_ref_info
|
||||
from core.activity_utils import (
|
||||
ANY_ACTIVITY_REGEX,
|
||||
get_activity_name_from_comment_name,
|
||||
get_icon_for_activity,
|
||||
get_ref_regex_for_activity,
|
||||
)
|
||||
from core.call_lookup_helper import get_call_info
|
||||
@@ -378,16 +379,10 @@ class Spot:
|
||||
logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}")
|
||||
|
||||
# Set activities based on propagation mode
|
||||
if self.propagation_mode == "Satellite":
|
||||
if not self.sig:
|
||||
self.sig = "AMSAT"
|
||||
if not any(activity_ref.sig == "AMSAT" for activity_ref in self.sig_refs):
|
||||
self.sig_refs.append(ActivityRef(sig="AMSAT"))
|
||||
if self.propagation_mode == "Earth-Moon-Earth":
|
||||
if not self.sig:
|
||||
self.sig = "EME"
|
||||
if not any(activity_ref.sig == "EME" for activity_ref in self.sig_refs):
|
||||
self.sig_refs.append(ActivityRef(sig="EME"))
|
||||
if self.propagation_mode == "Satellite" and not self.sig:
|
||||
self.sig = "Satellite"
|
||||
if self.propagation_mode == "Earth-Moon-Earth" and not self.sig:
|
||||
self.sig = "EME"
|
||||
|
||||
# Parse "de_grid -> dx_grid" structures from the comment
|
||||
if self.comment:
|
||||
@@ -499,10 +494,10 @@ class Spot:
|
||||
self.de_longitude = de_call_info.longitude
|
||||
self.de_grid = de_call_info.grid
|
||||
|
||||
# Icon for the spot should be the icon of the first activity ref if present, otherwise a radio tower
|
||||
# Icon for the spot should be the icon of its activity if known, otherwise a radio tower
|
||||
self.icon = "fa-tower-cell"
|
||||
if self.sig_refs and self.sig_refs[0].icon:
|
||||
self.icon = self.sig_refs[0].icon
|
||||
if self.sig and (activity_icon := get_icon_for_activity(self.sig)):
|
||||
self.icon = activity_icon
|
||||
|
||||
except Exception:
|
||||
logger.exception("Exception while inferring missing data from spot")
|
||||
|
||||
Reference in New Issue
Block a user