mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-31 15:59:34 -04:00
- 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.
19 lines
499 B
Python
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
|