Refactor activity names to use an enum instead of a string to avoid typos #147

This commit is contained in:
Ian Renton
2026-09-18 18:09:41 +01:00
parent ab79e7e01c
commit e5caf7353d
61 changed files with 735 additions and 638 deletions
+5 -4
View File
@@ -1,7 +1,8 @@
import json
from datetime import datetime
from core.enums import ActivityRefType, Mode
from core.enums import Mode
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.spot import Spot
from providers.spot.sse_spot_provider import SSESpotProvider
@@ -23,7 +24,7 @@ class WWBOTA(SSESpotProvider):
for ref in source_spot["references"]:
activity_ref = ActivityRef(
id=ref["reference"],
sig="WWBOTA",
sig=ActivityName.WWBOTA,
name=ref["name"],
latitude=ref["lat"],
longitude=ref["long"],
@@ -38,7 +39,7 @@ class WWBOTA(SSESpotProvider):
freq=float(source_spot["freq"]) * 1000000,
mode=Mode.from_name(source_spot["mode"].upper()) if "mode" in source_spot else None,
comment=source_spot["comment"],
sig="WWBOTA",
sig=ActivityName.WWBOTA,
sig_refs=refs,
time=datetime.fromisoformat(source_spot["time"].replace("Z", "+00:00")).timestamp(),
# WWBOTA spots can contain multiple references for bunkers being activated simultaneously. For
@@ -53,7 +54,7 @@ class WWBOTA(SSESpotProvider):
return spot if source_spot["type"] != "Test" else None
def can_submit_spot(self, activity):
return activity == "WWBOTA"
return activity == ActivityName.WWBOTA
def submit_spot(self, spot, credentials):
# TODO: Implement. WWBOTA API docs cover this: https://api.wwbota.org/#tag/Spots/operation/create_spot_spots__post