mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Refactor activity names to use an enum instead of a string to avoid typos #147
This commit is contained in:
+18
-17
@@ -4,7 +4,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from core.enums import ActivityRefType, Mode
|
||||
from core.enums import Mode
|
||||
from core.enums import ActivityName, ActivityRefType
|
||||
from core.url_data_cache import URLDataCache
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.spot import Spot
|
||||
@@ -106,40 +107,40 @@ class GMA(HTTPSpotProvider):
|
||||
spot.sig_refs
|
||||
and ref_info
|
||||
and "reftype" in ref_info
|
||||
and ref_info["reftype"] not in ["POTA", "WWFF"]
|
||||
and ref_info["reftype"] not in [ActivityName.POTA, ActivityName.WWFF]
|
||||
and (
|
||||
ref_info["reftype"] != "Summit" or "sota" not in ref_info or ref_info["sota"] == ""
|
||||
)
|
||||
):
|
||||
match ref_info["reftype"]:
|
||||
case "Summit":
|
||||
spot.sig_refs[0].sig = "GMA"
|
||||
spot.sig_refs[0].sig = ActivityName.GMA
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.SUMMIT
|
||||
spot.sig = "GMA"
|
||||
spot.sig = ActivityName.GMA
|
||||
case "IOTA Island":
|
||||
spot.sig_refs[0].sig = "IOTA"
|
||||
spot.sig_refs[0].sig = ActivityName.IOTA
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.ISLAND
|
||||
spot.sig = "IOTA"
|
||||
spot.sig = ActivityName.IOTA
|
||||
case "GMA Island":
|
||||
spot.sig_refs[0].sig = "GMA Islands"
|
||||
spot.sig_refs[0].sig = ActivityName.GMA_ISLANDS
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.ISLAND
|
||||
spot.sig = "GMA Islands"
|
||||
spot.sig = ActivityName.GMA_ISLANDS
|
||||
case "Lighthouse (ILLW)":
|
||||
spot.sig_refs[0].sig = "ILLW"
|
||||
spot.sig_refs[0].sig = ActivityName.ILLW
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.LIGHTHOUSE
|
||||
spot.sig = "ILLW"
|
||||
spot.sig = ActivityName.ILLW
|
||||
case "Lighthouse (ARLHS)":
|
||||
spot.sig_refs[0].sig = "ARLHS"
|
||||
spot.sig_refs[0].sig = ActivityName.ARLHS
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.LIGHTHOUSE
|
||||
spot.sig = "ARLHS"
|
||||
spot.sig = ActivityName.ARLHS
|
||||
case "Castle":
|
||||
spot.sig_refs[0].sig = "WCA"
|
||||
spot.sig_refs[0].sig = ActivityName.WCA
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.CASTLE
|
||||
spot.sig = "WCA"
|
||||
spot.sig = ActivityName.WCA
|
||||
case "Mill":
|
||||
spot.sig_refs[0].sig = "MOTA"
|
||||
spot.sig_refs[0].sig = ActivityName.MOTA
|
||||
spot.sig_refs[0].ref_type = ActivityRefType.MILL
|
||||
spot.sig = "MOTA"
|
||||
spot.sig = ActivityName.MOTA
|
||||
case _:
|
||||
logger.warning(
|
||||
f"GMA spot found with ref type {ref_info['reftype']}, developer needs to add support for this!"
|
||||
@@ -170,7 +171,7 @@ class GMA(HTTPSpotProvider):
|
||||
return new_spots
|
||||
|
||||
def can_submit_spot(self, activity):
|
||||
return activity == "GMA"
|
||||
return activity == ActivityName.GMA
|
||||
|
||||
def submit_spot(self, spot, credentials):
|
||||
# TODO: Implement.
|
||||
|
||||
Reference in New Issue
Block a user