File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -548,6 +548,17 @@ async def cancel_subscription_data(
548548 )
549549 return Organization .from_dict (org_data ) if org_data else None
550550
551+ async def is_subscription_activated (self , sub_id : str ) -> bool :
552+ """return true if subscription for this org was 'activated', eg. at least
553+ one user has signed up and changed the slug
554+ """
555+ org_data = await self .orgs .find_one ({"subscription.subId" : sub_id })
556+ if not org_data :
557+ return False
558+
559+ org = Organization .from_dict (org_data )
560+ return len (org .users ) > 0 and org .slug != str (org .id )
561+
551562 async def update_custom_storages (self , org : Organization ) -> bool :
552563 """Update storage on an existing organization"""
553564
Original file line number Diff line number Diff line change 3434 UserRole ,
3535 AddedResponseId ,
3636 UpdatedResponse ,
37+ SuccessResponse ,
3738 PaginatedSubscriptionEventResponse ,
3839 REASON_CANCELED ,
3940)
@@ -392,6 +393,18 @@ async def cancel_subscription(
392393
393394 assert org_ops .router
394395
396+ @app .get (
397+ "/subscriptions/is-activated/{sub_id}" ,
398+ tags = ["subscriptions" ],
399+ dependencies = [Depends (user_or_shared_secret_dep )],
400+ response_model = SuccessResponse ,
401+ )
402+ async def is_subscription_activated (
403+ sub_id : str ,
404+ ):
405+ result = await org_ops .is_subscription_activated (sub_id )
406+ return {"success" : result }
407+
395408 @app .get (
396409 "/subscriptions/events" ,
397410 tags = ["subscriptions" ],
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ def test_create_sub_org_and_invite_new_user(admin_auth_headers):
6868 new_subs_oid = org_id
6969
7070
71+ def test_validate_new_org_not_activated (admin_auth_headers ):
72+ r = requests .get (
73+ f"{ API_PREFIX } /subscriptions/is-activated/123" ,
74+ headers = admin_auth_headers ,
75+ )
76+ assert r .status_code == 200
77+ assert r .json ()["success" ] is False
78+
79+
7180def test_validate_new_org_with_quotas_and_name_is_uid (admin_auth_headers ):
7281 r = requests .get (f"{ API_PREFIX } /orgs/{ new_subs_oid } " , headers = admin_auth_headers )
7382 assert r .status_code == 200
@@ -126,6 +135,15 @@ def test_validate_new_org_with_quotas_and_update_name(admin_auth_headers):
126135 assert "subscription" in data
127136
128137
138+ def test_validate_new_org_is_activated (admin_auth_headers ):
139+ r = requests .get (
140+ f"{ API_PREFIX } /subscriptions/is-activated/123" ,
141+ headers = admin_auth_headers ,
142+ )
143+ assert r .status_code == 200
144+ assert r .json ()["success" ] is True
145+
146+
129147def test_create_sub_org_and_invite_existing_user_dupe_sub (admin_auth_headers ):
130148 r = requests .post (
131149 f"{ API_PREFIX } /subscriptions/create" ,
You can’t perform that action at this time.
0 commit comments