Skip to content
Snippets Groups Projects
Commit 49549cff authored by Tim Repke's avatar Tim Repke
Browse files

fix things

parent f63b930c
No related branches found
No related tags found
1 merge request!106Main
...@@ -302,7 +302,7 @@ async def get_assignment_indicators_for_scope(assignment_scope_id: str, ...@@ -302,7 +302,7 @@ async def get_assignment_indicators_for_scope(assignment_scope_id: str,
permissions=Depends(UserPermissionChecker('annotations_read'))) \ permissions=Depends(UserPermissionChecker('annotations_read'))) \
-> list[AssignmentScopeEntry]: -> list[AssignmentScopeEntry]:
return await read_assignment_overview_for_scope(assignment_scope_id=assignment_scope_id, return await read_assignment_overview_for_scope(assignment_scope_id=assignment_scope_id,
db_engine=db_engine) connection=db_engine)
@router.get('/annotate/assignments/scope/{assignment_scope_id}', response_model=list[AssignmentModel]) @router.get('/annotate/assignments/scope/{assignment_scope_id}', response_model=list[AssignmentModel])
......
...@@ -5,12 +5,11 @@ from sqlalchemy import select ...@@ -5,12 +5,11 @@ from sqlalchemy import select
from sqlalchemy import func as F from sqlalchemy import func as F
from server.data import db_engine from server.data import db_engine
from server.api.errors import \ from server.api.errors import NoDataForKeyError
NoDataForKeyError, \ from server.util.security import (
DataNotFoundWarning UserPermissionChecker,
from server.util.security import \
UserPermissionChecker, \
InsufficientPermissions InsufficientPermissions
)
from nacsos_data.util.auth import UserPermissions from nacsos_data.util.auth import UserPermissions
from nacsos_data.db.schemas.annotations import AssignmentScope from nacsos_data.db.schemas.annotations import AssignmentScope
...@@ -26,7 +25,7 @@ router = APIRouter() ...@@ -26,7 +25,7 @@ router = APIRouter()
@router.get('/scope/{assignment_scope_id}', response_model=list[HighlighterModel] | None) @router.get('/scope/{assignment_scope_id}', response_model=list[HighlighterModel] | None)
async def get_scope_highlighters(assignment_scope_id: str, async def get_scope_highlighters(assignment_scope_id: str,
permissions: UserPermissions = Depends(UserPermissionChecker('annotations_read'))) \ permissions: UserPermissions = Depends(UserPermissionChecker('annotations_read'))) \
-> list[HighlighterModel]: -> list[HighlighterModel] | None:
async with db_engine.session() as session: # type: AsyncSession async with db_engine.session() as session: # type: AsyncSession
highlighter_ids = select(F.unnest(AssignmentScope.highlighter_ids).label('highlighter_id')) \ highlighter_ids = select(F.unnest(AssignmentScope.highlighter_ids).label('highlighter_id')) \
.where(AssignmentScope.assignment_scope_id == assignment_scope_id) \ .where(AssignmentScope.assignment_scope_id == assignment_scope_id) \
...@@ -38,8 +37,10 @@ async def get_scope_highlighters(assignment_scope_id: str, ...@@ -38,8 +37,10 @@ async def get_scope_highlighters(assignment_scope_id: str,
result = (await session.scalars(stmt)).all() result = (await session.scalars(stmt)).all()
if result is not None and len(result) > 0: if result is not None and len(result) > 0:
return [HighlighterModel.model_validate(r.__dict__) for r in result] return [HighlighterModel.model_validate(r.__dict__) for r in result]
raise DataNotFoundWarning(f'No highlighter in project {permissions.permissions.project_id} '
f'for scope with id {assignment_scope_id}!') return None
# raise DataNotFoundWarning(f'No highlighter in project {permissions.permissions.project_id} '
# f'for scope with id {assignment_scope_id}!')
@router.get('/project', response_model=list[HighlighterModel]) @router.get('/project', response_model=list[HighlighterModel])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment