Skip to content

Commit 3b0c2cc

Browse files
Ensure that project_id is always considered in read_one
Only for the hotfix: Checkout pull request HEAD commit instead of merge commit
1 parent 6a20aa9 commit 3b0c2cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+114
-102
lines changed

.github/workflows/run-tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha }}
1517
- name: Install uv
16-
uses: astral-sh/setup-uv@v5
18+
uses: astral-sh/setup-uv@v7
1719
with:
1820
version: "latest"
1921
enable-cache: true
2022
- name: Setup python
21-
uses: actions/setup-python@v5
23+
uses: actions/setup-python@v6
2224
with:
2325
python-version-file: "pyproject.toml"
2426
- name: Check requirements

app/queries/common.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def router_read_one[T: BaseModel, I: Identifiable](
4141
id_: uuid.UUID,
4242
db: Session,
4343
db_model_class: type[I],
44-
authorized_project_id: uuid.UUID | None,
44+
user_context: UserContext | None,
4545
response_schema_class: SupportsModelValidate[T],
4646
apply_operations: ApplyOperations[I] | None,
4747
) -> T:
@@ -51,19 +51,21 @@ def router_read_one[T: BaseModel, I: Identifiable](
5151
id_: id of the entity to read.
5252
db: database session.
5353
db_model_class: database model class.
54-
authorized_project_id: id of the authorized project.
54+
user_context: the user context with project id and user information.
5555
response_schema_class: Pydantic schema class for the returned data.
5656
apply_operations: transformer function that modifies the select query.
5757
5858
Returns:
5959
the model data as a Pydantic model.
6060
"""
6161
query = sa.select(db_model_class).where(db_model_class.id == id_)
62-
if authorized_project_id and (
62+
if user_context and (
6363
id_model_class := get_declaring_class(db_model_class, "authorized_project_id")
6464
):
6565
query = constrain_to_accessible_entities(
66-
query, authorized_project_id, db_model_class=id_model_class
66+
query=query,
67+
project_id=user_context.project_id,
68+
db_model_class=id_model_class,
6769
)
6870
if apply_operations:
6971
query = apply_operations(query)

app/service/analysis_notebook_environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def read_one(
5151
db=db,
5252
id_=id_,
5353
db_model_class=AnalysisNotebookEnvironment,
54-
authorized_project_id=user_context.project_id,
54+
user_context=user_context,
5555
response_schema_class=AnalysisNotebookEnvironmentRead,
5656
apply_operations=_load,
5757
)
@@ -65,7 +65,7 @@ def admin_read_one(
6565
db=db,
6666
id_=id_,
6767
db_model_class=AnalysisNotebookEnvironment,
68-
authorized_project_id=None,
68+
user_context=None,
6969
response_schema_class=AnalysisNotebookEnvironmentRead,
7070
apply_operations=_load,
7171
)

app/service/analysis_notebook_execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def read_one(
5656
db=db,
5757
id_=id_,
5858
db_model_class=AnalysisNotebookExecution,
59-
authorized_project_id=user_context.project_id,
59+
user_context=user_context,
6060
response_schema_class=AnalysisNotebookExecutionRead,
6161
apply_operations=_load,
6262
)
@@ -70,7 +70,7 @@ def admin_read_one(
7070
db=db,
7171
id_=id_,
7272
db_model_class=AnalysisNotebookExecution,
73-
authorized_project_id=None,
73+
user_context=None,
7474
response_schema_class=AnalysisNotebookExecutionRead,
7575
apply_operations=_load,
7676
)

app/service/analysis_notebook_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def read_one(
5151
db=db,
5252
id_=id_,
5353
db_model_class=AnalysisNotebookResult,
54-
authorized_project_id=user_context.project_id,
54+
user_context=user_context,
5555
response_schema_class=AnalysisNotebookResultRead,
5656
apply_operations=_load,
5757
)
@@ -65,7 +65,7 @@ def admin_read_one(
6565
db=db,
6666
id_=id_,
6767
db_model_class=AnalysisNotebookResult,
68-
authorized_project_id=None,
68+
user_context=None,
6969
response_schema_class=AnalysisNotebookResultRead,
7070
apply_operations=_load,
7171
)

app/service/analysis_notebook_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def read_one(
5151
db=db,
5252
id_=id_,
5353
db_model_class=AnalysisNotebookTemplate,
54-
authorized_project_id=user_context.project_id,
54+
user_context=user_context,
5555
response_schema_class=AnalysisNotebookTemplateRead,
5656
apply_operations=_load,
5757
)
@@ -65,7 +65,7 @@ def admin_read_one(
6565
db=db,
6666
id_=id_,
6767
db_model_class=AnalysisNotebookTemplate,
68-
authorized_project_id=None,
68+
user_context=None,
6969
response_schema_class=AnalysisNotebookTemplateRead,
7070
apply_operations=_load,
7171
)

app/service/brain_atlas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def read_one(user_context: UserContextDep, atlas_id: uuid.UUID, db: SessionDep)
5252
id_=atlas_id,
5353
db=db,
5454
db_model_class=BrainAtlas,
55-
authorized_project_id=user_context.project_id,
55+
user_context=user_context,
5656
response_schema_class=BrainAtlasRead,
5757
apply_operations=_load_brain_atlas,
5858
)
@@ -63,7 +63,7 @@ def admin_read_one(db: SessionDep, atlas_id: uuid.UUID) -> BrainAtlasRead:
6363
id_=atlas_id,
6464
db=db,
6565
db_model_class=BrainAtlas,
66-
authorized_project_id=None,
66+
user_context=None,
6767
response_schema_class=BrainAtlasRead,
6868
apply_operations=_load_brain_atlas,
6969
)
@@ -102,7 +102,7 @@ def read_one_region(
102102
id_=atlas_region_id,
103103
db=db,
104104
db_model_class=BrainAtlasRegion,
105-
authorized_project_id=user_context.project_id,
105+
user_context=user_context,
106106
response_schema_class=BrainAtlasRegionRead,
107107
apply_operations=lambda select: select.filter(
108108
BrainAtlasRegion.brain_atlas_id == atlas_id

app/service/brain_region_hierarchy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def read_one(id_: uuid.UUID, db: SessionDep) -> BrainRegionHierarchyRead:
5050
id_=id_,
5151
db=db,
5252
db_model_class=BrainRegionHierarchy,
53-
authorized_project_id=None,
53+
user_context=None,
5454
response_schema_class=BrainRegionHierarchyRead,
5555
apply_operations=_load,
5656
)

app/service/calibration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def read_one(
5454
db=db,
5555
id_=id_,
5656
db_model_class=Calibration,
57-
authorized_project_id=user_context.project_id,
57+
user_context=user_context,
5858
response_schema_class=CalibrationRead,
5959
apply_operations=_load,
6060
)
@@ -68,7 +68,7 @@ def admin_read_one(
6868
db=db,
6969
id_=id_,
7070
db_model_class=Calibration,
71-
authorized_project_id=None,
71+
user_context=None,
7272
response_schema_class=CalibrationRead,
7373
apply_operations=_load,
7474
)

app/service/cell_composition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def read_one(
4444
db=db,
4545
id_=id_,
4646
db_model_class=CellComposition,
47-
authorized_project_id=user_context.project_id,
47+
user_context=user_context,
4848
response_schema_class=CellCompositionRead,
4949
apply_operations=_load,
5050
)
@@ -58,7 +58,7 @@ def admin_read_one(
5858
db=db,
5959
id_=id_,
6060
db_model_class=CellComposition,
61-
authorized_project_id=None,
61+
user_context=None,
6262
response_schema_class=CellCompositionRead,
6363
apply_operations=_load,
6464
)

0 commit comments

Comments
 (0)