Formatting

This commit is contained in:
Kohaku-Blueleaf
2025-10-16 01:24:58 +08:00
parent 8450f96aea
commit 1f1f2d4e22
5 changed files with 27 additions and 7 deletions

View File

@@ -70,7 +70,10 @@ def migrate_sqlite():
# Invitation multi-use fields
for column, sql in [
("max_usage", "ALTER TABLE invitation ADD COLUMN max_usage INTEGER DEFAULT NULL"),
(
"max_usage",
"ALTER TABLE invitation ADD COLUMN max_usage INTEGER DEFAULT NULL",
),
(
"usage_count",
"ALTER TABLE invitation ADD COLUMN usage_count INTEGER DEFAULT 0",
@@ -109,7 +112,10 @@ def migrate_postgres():
# Invitation multi-use fields
for column, sql in [
("max_usage", "ALTER TABLE invitation ADD COLUMN max_usage INTEGER DEFAULT NULL"),
(
"max_usage",
"ALTER TABLE invitation ADD COLUMN max_usage INTEGER DEFAULT NULL",
),
(
"usage_count",
"ALTER TABLE invitation ADD COLUMN usage_count INTEGER DEFAULT 0",

View File

@@ -407,7 +407,9 @@ async def create_register_invitation_admin(
# Verify organization exists
org = Organization.get_or_none(Organization.id == request.org_id)
if not org:
raise HTTPException(404, detail={"error": f"Organization not found: {request.org_id}"})
raise HTTPException(
404, detail={"error": f"Organization not found: {request.org_id}"}
)
org_name = org.name
else:
@@ -544,7 +546,9 @@ async def delete_invitation_admin(
delete_invitation(invitation)
logger.info(f"Admin deleted invitation: {token[:8]}... (action={invitation.action})")
logger.info(
f"Admin deleted invitation: {token[:8]}... (action={invitation.action})"
)
return {"success": True, "message": "Invitation deleted successfully"}

View File

@@ -127,7 +127,12 @@ async def create_org_invitation(
# Send email if SMTP enabled and email provided (async)
if req.email:
await asyncio.to_thread(
send_org_invitation_email, req.email, org.name, user.username, token, req.role
send_org_invitation_email,
req.email,
org.name,
user.username,
token,
req.role,
)
# Determine invitation type for logging

View File

@@ -178,7 +178,9 @@ def load_config(path: str = None) -> Config:
"KOHAKU_HUB_REQUIRE_EMAIL_VERIFICATION", "false"
).lower()
== "true",
invitation_only=os.environ.get("KOHAKU_HUB_INVITATION_ONLY", "false").lower()
invitation_only=os.environ.get(
"KOHAKU_HUB_INVITATION_ONLY", "false"
).lower()
== "true",
session_secret=os.environ.get(
"KOHAKU_HUB_SESSION_SECRET", "change-me-in-production"

View File

@@ -597,7 +597,10 @@ def check_invitation_available(invitation: Invitation) -> tuple[bool, str | None
else:
# Limited use (check count)
if invitation.usage_count >= invitation.max_usage:
return False, f"Invitation has reached maximum usage limit ({invitation.max_usage})"
return (
False,
f"Invitation has reached maximum usage limit ({invitation.max_usage})",
)
return True, None