3030)
3131from exceptions .exceptions import EmailSendFailedError
3232from utils .core .htmx import is_htmx_request , append_toast
33-
34- # Import the account router to generate URLs for login/register
33+ from utils .core .organizations import load_org_for_members_partial
3534from routers .core .account import router as account_router
36- from routers .core .organization import (
37- router as org_router ,
38- ) # Already imported, check usage
39- from routers .core .user import _load_org_for_members_partial
35+ from routers .core .organization import router as org_router
4036
4137# Setup logger
4238logger = getLogger ("uvicorn.error" )
@@ -85,7 +81,9 @@ async def create_invitation(
8581
8682 # Check if the current user has permission to invite users to this organization
8783 if not current_user .has_permission (ValidPermissions .INVITE_USER , organization ):
88- raise InsufficientPermissionsError ()
84+ raise InsufficientPermissionsError (
85+ "You don't have permission to invite users to this organization"
86+ )
8987
9088 # Verify the role exists and belongs to this organization
9189 role = session .get (Role , role_id )
@@ -164,7 +162,7 @@ async def create_invitation(
164162 # HTMX: return partial; non-HTMX: PRG redirect
165163 if is_htmx_request (request ):
166164 organization , user_permissions , active_invitations = (
167- _load_org_for_members_partial (session , organization_id , current_user )
165+ load_org_for_members_partial (session , organization_id , current_user )
168166 )
169167 response = templates .TemplateResponse (
170168 request ,
@@ -204,7 +202,9 @@ async def delete_invitation(
204202 raise OrganizationNotFoundError ()
205203
206204 if not current_user .has_permission (ValidPermissions .INVITE_USER , organization ):
207- raise InsufficientPermissionsError ()
205+ raise InsufficientPermissionsError (
206+ "You don't have permission to cancel invitations for this organization"
207+ )
208208
209209 invitation = session .get (Invitation , invitation_id )
210210 if not invitation or invitation .organization_id != organization_id :
@@ -215,7 +215,7 @@ async def delete_invitation(
215215
216216 if is_htmx_request (request ):
217217 organization , user_permissions , active_invitations = (
218- _load_org_for_members_partial (session , organization_id , current_user )
218+ load_org_for_members_partial (session , organization_id , current_user )
219219 )
220220 response = templates .TemplateResponse (
221221 request ,
0 commit comments