mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 22:37:44 +00:00
Refactor activity names to use an enum instead of a string to avoid typos #147
This commit is contained in:
@@ -7,6 +7,7 @@ import requests
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from core.enums import Mode
|
||||
from core.enums import ActivityName
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.spot import Spot
|
||||
from providers.spot.http_spot_provider import HTTPSpotProvider
|
||||
@@ -21,15 +22,15 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
SPOTS_URL = "https://www.parksnpeaks.org/api/ALL"
|
||||
SUBMIT_URL = "https://www.parksnpeaks.org/api/SPOT/"
|
||||
SUBMITTABLE_ACTIVITIES = [
|
||||
"POTA",
|
||||
"SOTA",
|
||||
"WWFF",
|
||||
"HEMA",
|
||||
"WOTA",
|
||||
"ZLOTA",
|
||||
"SIOTA",
|
||||
"KRMNPA",
|
||||
"SANPCPA",
|
||||
ActivityName.POTA,
|
||||
ActivityName.SOTA,
|
||||
ActivityName.WWFF,
|
||||
ActivityName.HEMA,
|
||||
ActivityName.WOTA,
|
||||
ActivityName.ZLOTA,
|
||||
ActivityName.SIOTA,
|
||||
ActivityName.KRMNPA,
|
||||
ActivityName.SANPCPA,
|
||||
]
|
||||
|
||||
def __init__(self, provider_config):
|
||||
@@ -68,7 +69,7 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
# programme with a defined set of references
|
||||
activity = source_spot["actClass"].upper()
|
||||
ref_id = source_spot["actSiteID"]
|
||||
if activity and activity != "" and activity != "QRP" and ref_id and ref_id != "":
|
||||
if activity and activity != "" and activity != ActivityName.QRP and ref_id and ref_id != "":
|
||||
spot.sig = activity
|
||||
activity_refs = [
|
||||
ActivityRef(
|
||||
@@ -84,15 +85,15 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
|
||||
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
|
||||
if activity not in [
|
||||
"POTA",
|
||||
"SOTA",
|
||||
"WWFF",
|
||||
"HEMA",
|
||||
"SIOTA",
|
||||
"ZLOTA",
|
||||
"KRMNPA",
|
||||
"SANPCPA",
|
||||
"LLOTA",
|
||||
ActivityName.POTA,
|
||||
ActivityName.SOTA,
|
||||
ActivityName.WWFF,
|
||||
ActivityName.HEMA,
|
||||
ActivityName.SIOTA,
|
||||
ActivityName.ZLOTA,
|
||||
ActivityName.KRMNPA,
|
||||
ActivityName.SANPCPA,
|
||||
ActivityName.LLOTA,
|
||||
]:
|
||||
logger.warning(f"PNP spot found with activity {activity}, developer needs to add support for this!")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user