Skip to content

Commit b3ff7cb

Browse files
fix: Enum is not extensible
1 parent e99235f commit b3ff7cb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

docs/customization.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ organization = session.exec(select(Organization).where(Organization.name == "Acm
258258
user.has_permission(permission, organization)
259259
```
260260

261-
You should create custom `AppPermissions` enum values for your application in `utils/app/` (if needed) and validate that users have the necessary permissions before allowing them to modify organization data resources.
261+
You can add custom permission enum values to the `ValidPermissions` enum in `utils/core/enums.py` (below the core permissions section) and validate that users have the necessary permissions before allowing them to modify organization data resources.
262262

263263
### Cascade deletes
264264

utils/app/enums.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

utils/core/enums.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
from utils.app.enums import AppPermissions
1+
from enum import Enum
22

3-
class ValidPermissions(AppPermissions):
3+
4+
class ValidPermissions(Enum):
5+
"""
6+
Core permissions - do not modify these:
7+
"""
48
DELETE_ORGANIZATION = "Delete Organization"
59
EDIT_ORGANIZATION = "Edit Organization"
610
INVITE_USER = "Invite User"
711
REMOVE_USER = "Remove User"
812
EDIT_USER_ROLE = "Edit User Role"
913
CREATE_ROLE = "Create Role"
1014
DELETE_ROLE = "Delete Role"
11-
EDIT_ROLE = "Edit Role"
15+
EDIT_ROLE = "Edit Role"
16+
17+
# Add additional app-specific permissions below this line:
18+
READ_ORGANIZATION_RESOURCES = "Read Organization Resources"
19+
WRITE_ORGANIZATION_RESOURCES = "Write Organization Resources"
20+
DELETE_ORGANIZATION_RESOURCES = "Delete Organization Resources"

0 commit comments

Comments
 (0)