mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-31 15:59:34 -04:00
* Add new default light and dark themes to match AdventureLog styles * Allow different theme for site and maps Fixes #1130 * Update settings page to use translation keys for currency and map style descriptions * Add global flag to CollectionItineraryItemSerializer and implement map view persistence in frontend * Update appVersion to v0.12.0-main-052126 * Enhance permissions for shared collections and restrict publicity changes to owners only * Update appVersion to v0.12.1-beta-052126 * Add new localization strings and descriptions for various languages - Updated Spanish (es.json) with new map style and preferred currency descriptions. - Enhanced French (fr.json) with additional details for Strava activities and currency descriptions. - Added new strings in Hungarian (hu.json) for map style and preferred currency. - Included additional details in Italian (it.json) for Strava activities and currency descriptions. - Updated Japanese (ja.json) with new strings for map style and preferred currency. - Enhanced Korean (ko.json) with additional details for Strava activities and currency descriptions. - Added new strings in Dutch (nl.json) for map style and preferred currency. - Updated Norwegian (no.json) with new strings for map style and preferred currency. - Enhanced Polish (pl.json) with additional details for Strava activities and currency descriptions. - Updated Brazilian Portuguese (pt-br.json) with new map style and preferred currency descriptions. - Added new strings in Romanian (ro.json) for additional details and currency descriptions. - Enhanced Russian (ru.json) with new strings for map style and preferred currency. - Updated Slovak (sk.json) with additional details for map style and preferred currency. - Enhanced Swedish (sv.json) with new strings for map style and preferred currency. - Added new strings in Turkish (tr.json) for map style and preferred currency. - Updated Ukrainian (uk.json) with new strings for map style and preferred currency. - Enhanced Chinese (zh.json) with additional details for map style and preferred currency. * feat: Implement cloud billing system with subscription management - Added billing app with models, serializers, views, and admin configuration for Subscription. - Integrated Stripe for payment processing and subscription management. - Created middleware for cloud access control based on user subscriptions. - Developed frontend components for subscription status and billing management. - Updated settings to include cloud mode and Stripe configuration. - Added routes for billing and subscription management in the API. - Implemented user subscription creation and management on user registration and checkout. * feat: Implement media storage limit and usage tracking - Added media storage limit configuration in settings. - Introduced utility functions for managing media storage limits and usage. - Updated models to delete media files using storage backend. - Enhanced serializers to build media URLs dynamically. - Implemented media usage tracking in user views and added endpoint for fetching media usage. - Updated frontend to display media storage usage and limits. - Added translations for media storage related strings in multiple languages. * feat: Implement conditional throttling for various external services and update settings for rate limits
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from datetime import timedelta
|
|
|
|
from django.conf import settings
|
|
from django.utils import timezone
|
|
|
|
from billing.models import Subscription
|
|
|
|
|
|
def get_or_create_subscription(user) -> Subscription:
|
|
if settings.CLOUD_MODE:
|
|
trial_ends_at = timezone.now() + timedelta(days=settings.CLOUD_TRIAL_DAYS)
|
|
defaults = {
|
|
"status": Subscription.STATUS_TRIAL,
|
|
"trial_ends_at": trial_ends_at,
|
|
}
|
|
else:
|
|
defaults = {"status": Subscription.STATUS_ACTIVE, "trial_ends_at": None}
|
|
|
|
subscription, _ = Subscription.objects.get_or_create(user=user, defaults=defaults)
|
|
return subscription
|
|
|
|
|
|
def has_access(user, subscription: Subscription | None = None) -> bool:
|
|
if not settings.CLOUD_MODE:
|
|
return True
|
|
|
|
if subscription is None:
|
|
subscription = get_or_create_subscription(user)
|
|
|
|
if subscription.status == Subscription.STATUS_ACTIVE:
|
|
return True
|
|
|
|
if subscription.status == Subscription.STATUS_TRIAL:
|
|
if subscription.trial_ends_at is None:
|
|
return True
|
|
return subscription.trial_ends_at >= timezone.now()
|
|
|
|
return False
|