Files
AdventureLog/backend/server/adventures/utils/location_access.py
Sean Morley bf063b0632 Refactor sunrise/sunset functionality and introduce caching
- Renamed `ExternalSunTimesThrottle` to `ExternalSunriseSunsetThrottle` for clarity.
- Added `SunriseSunsetAPI` view to handle sunrise and sunset data retrieval.
- Implemented caching for sunrise/sunset data using `get_or_fetch_cached`.
- Created new service functions for fetching sunrise/sunset data from the external API.
- Updated related tests to ensure proper functionality and caching behavior.
- Removed deprecated sun times handling from the `LocationViewSet` for cleaner code.
2026-07-08 20:15:09 -04:00

19 lines
499 B
Python

from adventures.models import Location
def user_can_access_location(location: Location, user) -> bool:
if location.is_public:
return True
if user.is_authenticated and location.user == user:
return True
if user.is_authenticated:
for collection in location.collections.all():
if collection.user == user:
return True
if collection.shared_with.filter(uuid=user.uuid).exists():
return True
return False