mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-24 16:24:32 +00:00
First attempt at converting "sig" to "activity" for v3
This commit is contained in:
+10
-11
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
from pyhamtools.locator import locator_to_latlong, latlong_to_locator
|
||||
from pyhamtools.locator import latlong_to_locator, locator_to_latlong
|
||||
|
||||
from core.activity_lookup_helper import populate_missing_activity_ref_info
|
||||
from core.activity_utils import get_icon_for_activity
|
||||
@@ -66,11 +66,10 @@ class Alert:
|
||||
|
||||
# Activity info
|
||||
|
||||
# Activity (e.g. outdoor activity programme such as POTA). Still named "sig" for API backwards compatibility.
|
||||
sig: str | None = None
|
||||
# Activity references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO. Still named
|
||||
# "sig_refs" for API backwards compatibility.
|
||||
sig_refs: list = field(default_factory=list)
|
||||
# Activity (e.g. outdoor activity programme such as POTA).
|
||||
activity: str | None = None
|
||||
# Activity references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO.
|
||||
activity_refs: list = field(default_factory=list)
|
||||
|
||||
# Timing info
|
||||
|
||||
@@ -131,8 +130,8 @@ class Alert:
|
||||
self.dx_flag = get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
|
||||
# Fetch activity data, and set a real position if we can get one.
|
||||
if self.sig_refs:
|
||||
for activity_ref in self.sig_refs:
|
||||
if self.activity_refs:
|
||||
for activity_ref in self.activity_refs:
|
||||
activity_ref = populate_missing_activity_ref_info(activity_ref)
|
||||
# If the alert itself doesn't have location yet, but the activity ref does, extract it
|
||||
if activity_ref.grid and not self.dx_grid:
|
||||
@@ -148,8 +147,8 @@ class Alert:
|
||||
|
||||
# If the spot itself doesn't have an activity yet, but we have at least one activity reference, take that
|
||||
# reference's activity and apply it to the whole spot.
|
||||
if self.sig_refs and self.sig_refs[0] and not self.sig:
|
||||
self.sig = self.sig_refs[0].sig
|
||||
if self.activity_refs and self.activity_refs[0] and not self.activity:
|
||||
self.activity = self.activity_refs[0].activity
|
||||
|
||||
# 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):
|
||||
@@ -182,7 +181,7 @@ class Alert:
|
||||
|
||||
# Icon for the alert should be the icon of its activity if known, otherwise a radio tower
|
||||
self.icon = "fa-tower-cell"
|
||||
if self.sig and (activity_icon := get_icon_for_activity(self.sig)):
|
||||
if self.activity and (activity_icon := get_icon_for_activity(self.activity)):
|
||||
self.icon = activity_icon
|
||||
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user