mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: implement usage limits across the app
This commit is contained in:
parent
85ffb44d93
commit
a5fbf49304
15 changed files with 281 additions and 160 deletions
|
|
@ -6,6 +6,10 @@ from sqlmodel import Session, select
|
|||
from src.db.organizations import Organization
|
||||
from src.db.user_organizations import UserOrganization
|
||||
from src.db.users import AnonymousUser, PublicUser, User
|
||||
from src.security.features_utils.usage import (
|
||||
check_limits_with_usage,
|
||||
increase_feature_usage,
|
||||
)
|
||||
from src.services.orgs.invites import get_invite_code
|
||||
from src.services.orgs.orgs import get_org_join_mechanism
|
||||
|
||||
|
|
@ -27,12 +31,14 @@ async def join_org(
|
|||
|
||||
org = result.first()
|
||||
|
||||
if not org:
|
||||
if not org or org.id is None:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail="Organization not found",
|
||||
)
|
||||
|
||||
check_limits_with_usage("members", org.id, db_session)
|
||||
|
||||
join_method = await get_org_join_mechanism(
|
||||
request, args.org_id, current_user, db_session
|
||||
)
|
||||
|
|
@ -104,6 +110,8 @@ async def join_org(
|
|||
db_session.add(user_organization)
|
||||
db_session.commit()
|
||||
|
||||
increase_feature_usage("members", org.id, db_session)
|
||||
|
||||
return "Great, You're part of the Organization"
|
||||
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue