Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions docs/using/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ For example, if the submission identifier we received was '1', we can query
"comment": "Clarification the reviewer should be aware of.",
"identifier": 1,
"request_date": "2025-03-20T09:09:54",
"aiod_entry_identifier": 212,
"reviews": [],
"assets": [{
...
}]
"assets": [
{
"name": "The name of this resource",
"aiod_entry": { "status": "published", ... },
"keyword": ["AI", "Research"],
...
}
]
}
```
No reviews have yet been performed on the submission, as indicated by the empty list
Expand Down Expand Up @@ -155,7 +159,6 @@ endpoint will provide you with the reviewer feedback, e.g.:
"comment": "Clarification the reviewer should be aware of.",
"identifier": 1,
"request_date": "2025-03-20T09:09:54",
"aiod_entry_identifier": 212,
"reviews": [
{
"comment": "Several critical fields have incomplete information. Please improve the description, and add a house number to the address.",
Expand All @@ -165,7 +168,14 @@ endpoint will provide you with the reviewer feedback, e.g.:
"submission_identifier": 1
}
],
"assets": [{ ... }]
"assets": [
{
"name": "The name of this resource",
"aiod_entry": { "status": "draft", ... },
"keyword": ["AI", "Research"],
...
}
]
}
```
You'll find reviewer comments under "reviews".
Expand Down
65 changes: 45 additions & 20 deletions src/routers/review_router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import enum
from routers.resource_routers import versioned_routers

from http import HTTPStatus
from typing import Sequence, Literal, cast
from typing import Sequence, Literal, cast, Any

from fastapi import APIRouter, HTTPException, Depends
from sqlmodel import select, Session
Expand Down Expand Up @@ -35,12 +37,52 @@ def create(url_prefix: str, version: Version) -> APIRouter:
description="Retract an asset under review, setting its status to 'draft'.",
)(retract_submission)

router.get(
@router.get(
"/submissions/{identifier}",
tags=["Reviewing"],
description="Retrieve a specific submission.",
response_model=SubmissionView,
)(get_submission)
)
def get_submission(
identifier: int,
user: KeycloakUser = Depends(get_user_or_raise), # noqa: B008
session: Session = Depends(get_session), # noqa: B008
) -> Any:
submission = session.get(Submission, identifier)
if not submission:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail=f"No submission with identifier {identifier} found.",
)
if not user.is_reviewer and submission.requestee_identifier != user._subject_identifier:
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN,
detail=f"You do not have permission to view submission "
f"with identifier {identifier}.",
)

# GET THE CONVERTERS FOR THIS VERSION
orm_to_read = {
r.resource_class.__tablename__: r.orm_to_read
for r in versioned_routers.get(version, [])
}

# APPLY CONVERTERS TO EACH ASSET
deserialized_assets = []
for asset in submission.assets:
converter = orm_to_read.get(asset.__tablename__)
if converter:
deserialized_assets.append(converter(asset))
else:
deserialized_assets.append(asset)

return SubmissionView(
identifier=submission.identifier,
request_date=submission.request_date,
comment=submission.comment,
reviews=submission.reviews,
assets=deserialized_assets,
)

router.get(
"/submissions",
Expand Down Expand Up @@ -119,23 +161,6 @@ def list_submissions(
return _get_submissions_by_state(which=mode, from_requestee=user_filter) # type: ignore[arg-type]
raise ValueError(f"`mode` should be one of {ListMode!r} but is {mode!r}.")


def get_submission(
identifier: int,
user: KeycloakUser = Depends(get_user_or_raise), # noqa: B008
session: Session = Depends(get_session), # noqa: B008
) -> Submission:
submission = session.get(Submission, identifier)
if not submission:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail=f"No submission with identifier {identifier} found.",
)
if not user.is_reviewer and submission.requestee_identifier != user._subject_identifier:
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN,
detail=f"You do not have permission to view submission with identifier {identifier}.",
)
return submission


Expand Down
Loading