Allow spots and alerts to have multiple activities #143

This commit is contained in:
Ian Renton
2026-09-24 22:57:46 +01:00
parent 81166dccab
commit 4477942bec
34 changed files with 217 additions and 157 deletions
+5 -5
View File
@@ -197,19 +197,19 @@ def spot_allowed_by_query(spot, query):
if not spot.source or spot.source not in sources:
return False
case "activity":
# If a list of activities is provided, the spot must have an activity and it must match one of them.
# The special activity "NO_ACTIVITY", when supplied in the list, matches spots with no activity.
# If a list of activities is provided, the spot must have at least one activity that matches one of
# them. The special activity "NO_ACTIVITY", when supplied in the list, matches spots with no activity.
activities = query.get(k).split(",")
include_no_activity = "NO_ACTIVITY" in activities
if not spot.activity and not include_no_activity:
if not spot.activities and not include_no_activity:
return False
if spot.activity and spot.activity not in activities:
if spot.activities and not any(a in activities for a in spot.activities):
return False
case "needs_activity":
# If true, an activity is required, regardless of what it is, it just can't be missing. Mutually
# exclusive with supplying the special "NO_ACTIVITY" parameter to the "activity" query param.
needs_activity = query.get(k).upper() == "TRUE"
if needs_activity and not spot.activity:
if needs_activity and not spot.activities:
return False
case "needs_activity_ref":
# If true, at least one activity ref is required, regardless of what it is, it just can't be missing.