Changeset View
Changeset View
Standalone View
Standalone View
common/queries.py
| Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | def has_active_subscription(user: User) -> bool: | ||||
| """Check subscription status of the given user. | """Check subscription status of the given user. | ||||
| Currently active subscription means having a custom `can_view_content` permission, | Currently active subscription means having a custom `can_view_content` permission, | ||||
| given to users via different kinds of groups, for example: | given to users via different kinds of groups, for example: | ||||
| * "demo" | * "demo" | ||||
| * "subscriber" | * "subscriber" | ||||
| * "_org_<name>" for organisation-level subscriptions. | * "_org_<name>" for organisation-level subscriptions. | ||||
| """ | """ | ||||
| import subscriptions.queries | |||||
| if not user: | if not user: | ||||
| return False | return False | ||||
| return user.has_perm('users.can_view_content') | |||||
| # The old way, that supports Store-based and manual team subscriptions | |||||
| if user.has_perm('users.can_view_content'): | |||||
| return True | |||||
| # The new way, with subscriptions managed by Cloud itself | |||||
| return subscriptions.queries.has_active_subscription(user) | |||||