Skip to content
Merged
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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ repos:
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
Expand Down
8 changes: 5 additions & 3 deletions bats_ai/core/views/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ def delete_recording(
try:
recording = Recording.objects.get(pk=id)

# Check if the user owns the recording or if the recording is public
if recording.owner == request.user or recording.public:
# Check if the user owns the recording
if recording.owner == request.user:
# Delete the annotation
recording.delete()
return {"message": "Recording deleted successfully"}
Expand Down Expand Up @@ -881,7 +881,7 @@ def get_other_user_annotations(request: HttpRequest, id: int):
recording = Recording.objects.get(pk=id)

# Check if the user owns the recording or if the recording is public
if recording.owner == request.user or recording.public:
if recording.owner == request.user or request.user.is_superuser:
# Query annotations associated with the recording that are owned by other users
annotations_qs = Annotations.objects.filter(recording=recording).exclude(
owner=request.user
Expand Down Expand Up @@ -1007,6 +1007,8 @@ def patch_annotation(
annotation_instance = Annotations.objects.get(
pk=id, recording=recording, owner=request.user
)
if annotation_instance is None:
return {"error": "Annotation not found"}

# Update annotation details
if annotation.start_time is not None:
Expand Down
7 changes: 5 additions & 2 deletions bats_ai/core/views/recording_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def update_recording_annotation(
annotation = RecordingAnnotation.objects.get(pk=id)

# Check permission
if annotation.owner != request.user:
raise HttpError(403, "Permission denied.")

if annotation.recording.owner != request.user and not annotation.recording.public:
raise HttpError(403, "Permission denied.")

Expand Down Expand Up @@ -186,8 +189,8 @@ def delete_recording_annotation(request: HttpRequest, id: int):

annotation = RecordingAnnotation.objects.get(pk=id)

# Check permission
if annotation.recording.owner != request.user:
# Check permission: only the annotation owner may delete their own
if annotation.owner != request.user:
raise HttpError(403, "Permission denied.")

annotation.delete()
Expand Down