Skip to content

Commit 326ddb0

Browse files
authored
Merge pull request #607 from VariantEffect/tests/bencap/543/permissions-module-direct-testing
Permissions Module Refactor and Direct Testing
2 parents 796a6f0 + 6e4bfa0 commit 326ddb0

38 files changed

+5112
-691
lines changed

src/mavedb/lib/permissions.py

Lines changed: 0 additions & 506 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Permission system for MaveDB entities.
3+
4+
This module provides a comprehensive permission system for checking user access
5+
to various entity types including ScoreSets, Experiments, Collections, etc.
6+
7+
Main Functions:
8+
has_permission: Check if a user has permission for an action on an entity
9+
assert_permission: Assert permission or raise exception
10+
11+
Usage:
12+
>>> from mavedb.lib.permissions import Action, has_permission, assert_permission
13+
>>>
14+
>>> # Check permission and handle response
15+
>>> result = has_permission(user_data, score_set, Action.READ)
16+
>>> if result.permitted:
17+
... # User has access
18+
... pass
19+
>>>
20+
>>> # Assert permission (raises exception if denied)
21+
>>> assert_permission(user_data, score_set, Action.UPDATE)
22+
"""
23+
24+
from .actions import Action
25+
from .core import assert_permission, has_permission
26+
27+
__all__ = ["has_permission", "assert_permission", "Action"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from enum import Enum
2+
3+
4+
class Action(Enum):
5+
LOOKUP = "lookup"
6+
READ = "read"
7+
UPDATE = "update"
8+
DELETE = "delete"
9+
ADD_EXPERIMENT = "add_experiment"
10+
ADD_SCORE_SET = "add_score_set"
11+
SET_SCORES = "set_scores"
12+
ADD_ROLE = "add_role"
13+
PUBLISH = "publish"
14+
ADD_BADGE = "add_badge"
15+
CHANGE_RANK = "change_rank"

0 commit comments

Comments
 (0)