mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-24 08:14:32 +00:00
48 lines
3.0 KiB
Python
48 lines
3.0 KiB
Python
from dataclasses import dataclass, field
|
|
|
|
from core.enums import ActivityName, ActivityRefType, ActivityType
|
|
|
|
|
|
@dataclass
|
|
class Activity:
|
|
"""Data class that defines an Activity. Each contains a name and a longer form description. They also contain
|
|
comment_names which attempts to separate out the way people might refer to it in cluster comments from how it is
|
|
referred to in the UI & API. (For example, "TOTA" in cluster spot comments almost always means Towers on the Air,
|
|
but no single programme is referred to in the UI as "TOTA" as it's ambiguous between Towers, Toilets and Tiles.
|
|
And while Beaches got the name "BOTA" first, "BOTA" spots are much more likely to be bunkers.) Finally, there is a
|
|
ref_regex which provides a regular expression to match what references (such as parks and summits) look like for
|
|
that programme."""
|
|
|
|
# Activity name as used in the UI and API, e.g. "Towers"
|
|
name: ActivityName
|
|
# Description, e.g. "Towers on the Air"
|
|
description: str
|
|
# Type, either Worldwide, Regional or Event. Used for sorting in the web UI.
|
|
activity_type: ActivityType
|
|
# Whether this activity has a fixed set of references (e.g. parks) with some sort of ID to "activate"
|
|
has_refs: bool
|
|
# Identifies that the activity's reference ID structure defined by its regex is unique across all programmes and
|
|
# anything else we expect a user to put in a spot comment, and therefore we can pull references out of
|
|
# spot comments without also needing to see the activity name first. For example, "OHFF-1234" or "B/G-1234" are
|
|
# obviously WWFF and WWBOTA, nothing else looks like those. But "SZ09" could be WAB or Tiles, "GB1234" could
|
|
# conceivably be POTA or ILLW, etc. So in those cases we need to see the name of the activity itself immediately
|
|
# before it.
|
|
refs_globally_unique: bool
|
|
# Reference type, what gets activated e.g. Park, Summit. May be None if the activity is for multiple types of
|
|
# things, in which case the spot data will have to provide this instead.
|
|
ref_type: ActivityRefType | None = None
|
|
# Regex matcher for references, e.g. for POTA r"[A-Z]{2}\-\d+". Only set when has_references is True and we know
|
|
# the fixed format references take for this activity.
|
|
ref_regex: str | None = None
|
|
# Activity names as they might appear in cluster spot comments, e.g. ["TOTA"]
|
|
comment_names: list[str] = field(default_factory=list)
|
|
# Icon to use in the UI when referencing this activity. Chosen from the Font Awesome set.
|
|
icon: str | None = None
|
|
# Emoji flag for the country or region where this activity is relevant, if any. If None, this implies the
|
|
# activity is in worldwide usage.
|
|
region_flag: str | None = None
|
|
# Can alerts ever have this activity? A lot of activities can be figured out from spot comments but can never
|
|
# occur in alerts, so to avoid showing all activities on the "upcoming" page, we allow it to filter based on
|
|
# this.
|
|
alerts_possible: bool = False
|