Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/capacity/limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from core.capacity.logs import emit
from core.capacity.threads import RedisThread
from core.common.utils import get_event_metadata
from core.users.constants import CORE_USER_GROUP, EARLY_ACCESS_GROUP
from core.users.constants import CORE_USER_GROUP, EARLY_ACCESS_GROUP, PRO_GROUP

_NOW_MS = """
if redis.replicate_commands then redis.replicate_commands() end
Expand Down Expand Up @@ -248,13 +248,13 @@ def get_not_after_ms():


def get_tier(user):
"""The user's highest plan tier, as capabilities resolve it: staff > core > early_access > preview."""
"""The user's highest plan tier, as capabilities resolve it: staff > core > early_access (also pro) > preview."""
if user.is_staff or user.is_superuser:
return TIER_STAFF
groups = set(user.groups.values_list('name', flat=True))
if CORE_USER_GROUP in groups:
return TIER_CORE
if EARLY_ACCESS_GROUP in groups:
if EARLY_ACCESS_GROUP in groups or PRO_GROUP in groups:
return TIER_EARLY_ACCESS
return TIER_PREVIEW

Expand Down
3 changes: 2 additions & 1 deletion core/capacity/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from core.capacity.threads import RedisThread
from core.common.tests import OCLTestCase, OCLAPITestCase, PREVIEW_GROUP_NAME
from core.common.utils import get_event_metadata
from core.users.constants import CORE_USER_GROUP, EARLY_ACCESS_GROUP
from core.users.constants import CORE_USER_GROUP, EARLY_ACCESS_GROUP, PRO_GROUP
from core.users.tests.factories import UserProfileFactory


Expand Down Expand Up @@ -239,6 +239,7 @@ def test_get_tier(self):
self.assertEqual(get_tier(make_user(is_superuser=True)), 'staff')
self.assertEqual(get_tier(make_user(CORE_USER_GROUP)), 'core')
self.assertEqual(get_tier(make_user(EARLY_ACCESS_GROUP)), 'early_access')
self.assertEqual(get_tier(make_user(PRO_GROUP)), 'early_access')
self.assertEqual(get_tier(make_user(PREVIEW_GROUP_NAME)), 'preview')
self.assertEqual(get_tier(make_user()), 'preview')
user = make_user(PREVIEW_GROUP_NAME)
Expand Down
1 change: 1 addition & 0 deletions core/users/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
PREVIEW_GROUP = 'preview'
PREVIEW_GRANDFATHERED_GROUP = 'preview_grandfathered' # existing accounts (ocl_online#230); layered on `preview`
EARLY_ACCESS_GROUP = 'early_access'
PRO_GROUP = 'pro' # gets early access's capacity tier (ocl_online#517)
BULK_IMPORT_ADVANCED_PERMISSION = 'users.bulk_import_advanced'
BULK_IMPORT_PRIORITY_PERMISSION = 'users.bulk_import_priority'
LIST_UNPAGINATED_PERMISSION = 'users.list_unpaginated'
Loading