Skip to content

Commit

Permalink
limit other user view to own recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Jan 31, 2024
1 parent 7a85e98 commit c546c1d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
64 changes: 34 additions & 30 deletions bats_ai/core/views/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,25 @@ def get_spectrogram(request: HttpRequest, id: int):
},
}
# Get distinct other users who have made annotations on the recording
other_users_qs = (
Annotations.objects.filter(recording=recording)
.exclude(owner=request.user)
.values('owner__username', 'owner__email', 'owner__pk')
.distinct()
)
if recording.owner == request.user:
other_users_qs = (
Annotations.objects.filter(recording=recording)
.exclude(owner=request.user)
.values('owner__username', 'owner__email', 'owner__pk')
.distinct()
)

other_users = [
{
'username': user['owner__username'],
'email': user['owner__email'],
'id': user['owner__pk'],
}
for user in other_users_qs
]
other_users = [
{
'username': user['owner__username'],
'email': user['owner__email'],
'id': user['owner__pk'],
}
for user in other_users_qs
]

spectro_data['otherUsers'] = other_users

spectro_data['otherUsers'] = other_users
spectro_data['currentUser'] = request.user.email

annotations_qs = Annotations.objects.filter(recording=recording, owner=request.user)
Expand Down Expand Up @@ -221,23 +223,25 @@ def get_spectrogram_compressed(request: HttpRequest, id: int):
}

# Get distinct other users who have made annotations on the recording
other_users_qs = (
Annotations.objects.filter(recording=recording)
.exclude(owner=request.user)
.values('owner__username', 'owner__email', 'owner__pk')
.distinct()
)
if recording.owner == request.user:
other_users_qs = (
Annotations.objects.filter(recording=recording)
.exclude(owner=request.user)
.values('owner__username', 'owner__email', 'owner__pk')
.distinct()
)

other_users = [
{
'username': user['owner__username'],
'email': user['owner__email'],
'id': user['owner__pk'],
}
for user in other_users_qs
]
other_users = [
{
'username': user['owner__username'],
'email': user['owner__email'],
'id': user['owner__pk'],
}
for user in other_users_qs
]

spectro_data['otherUsers'] = other_users

spectro_data['otherUsers'] = other_users
spectro_data['currentUser'] = request.user.email

annotations_qs = Annotations.objects.filter(recording=recording, owner=request.user)
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/Recordings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default defineComponent({
<v-card-title>
<v-row class="py-2">
<div>
Recordings
My Recordings
</div>
<v-spacer />
<v-btn
Expand Down

0 comments on commit c546c1d

Please sign in to comment.