mirror of
https://github.com/KohakuBlueleaf/KohakuHub.git
synced 2026-03-11 17:34:08 -05:00
Formatting
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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"}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user