Skip to content

Commit 5aaca19

Browse files
feat : instrument data access audit logs (#2054)
* feat: instrument applet:subject:view audit events * feat: instrument applet:answer:view audit events * feat: instrument applet:answer:assessment:view + applet:answer:identifier:view audit events * feat: instrument applet:answer:note:view audit events * feat: instrument applet:answer:export audit events * fix: log submit_ids in curious_submit_id instead of curious_answer_id * feat: log curious_subject_id wherever available for applet:subject:view * feat: log curious_answer_id wherever available for applet:answer:* events The branch already logged curious_answer_id for the answer:* endpoints that have an answer_id in the URL. This commit covers the remaining endpoints where answer_ids are reachable from the response or query filters * fix: move post-fetch processing inside try in applet_answers_export * feat: address PR review comments - additional curious_* fields * fix: use subjects_by_applet.get(applet_id) in error path and log curious_answer_id in submission assessment retrieve
1 parent f49b95c commit 5aaca19

9 files changed

Lines changed: 1820 additions & 209 deletions

File tree

src/apps/answers/api.py

Lines changed: 397 additions & 86 deletions
Large diffs are not rendered by default.

src/apps/answers/crud/notes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async def map_users_and_notes(
7979
result.append(
8080
AnswerNoteDetail(
8181
id=note.id,
82+
answer_id=note.answer_id,
8283
user=dict(
8384
id=note_user.id,
8485
first_name=note_user.first_name,

src/apps/answers/domain/answers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ class Reviewer(InternalModel):
458458

459459
class AnswerReview(InternalModel):
460460
id: uuid.UUID
461+
answer_id: uuid.UUID
461462
reviewer_public_key: str | None = None
462463
answer: str | None = None
463464
item_ids: Annotated[list[str], Field(default_factory=list)]
@@ -519,6 +520,7 @@ class NoteOwner(InternalModel):
519520

520521
class AnswerNoteDetail(InternalModel):
521522
id: uuid.UUID
523+
answer_id: uuid.UUID
522524
user: NoteOwner
523525
note: str
524526
created_at: datetime.datetime

src/apps/answers/service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,7 @@ async def _prepare_answer_reviews(
21212121
results.append(
21222122
AnswerReview(
21232123
id=schema.id,
2124+
answer_id=schema.answer_id,
21242125
reviewer_public_key=schema.user_public_key if can_view else None,
21252126
answer=schema.answer if can_view else None,
21262127
item_ids=schema.item_ids,

0 commit comments

Comments
 (0)