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
22 changes: 21 additions & 1 deletion src/apps/api/views/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,27 @@ def update(self, request, *args, **kwargs):
queue = self.get_object()
if request.user != queue.owner and not request.user.is_superuser:
raise PermissionDenied("Cannot update a queue that is not yours")
return super().update(request, *args, **kwargs)

# Get the original value of is_public before updating
before_update_queue_is_public = queue.is_public

# Get the competitions that are using this queue
competitions = queue.competitions.all()

# Update the queue
updated_queue_response = super().update(request, *args, **kwargs)

# If the queue `is_public`` field is updated to False, then update competitions
if 'is_public' in request.data and not request.data['is_public'] and before_update_queue_is_public:

# Set the queue field in all competitions to NULL
# which do not belong to the user
for competition in competitions:
if competition.created_by != request.user:
competition.queue = None
competition.save()

return updated_queue_response

def destroy(self, request, *args, **kwargs):
instance = self.get_object()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
// Note: Passing `public=true` so default behavior is users can search for public queues
apiSettings: {
url: `${URLS.API}queues/?search={query}&public=true`,
cache: false
},
clearable: true,
minCharacters: 2,
Expand Down
5 changes: 2 additions & 3 deletions src/static/riot/queues/management.tag
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@
</tr>
</tbody>
<tfoot>
<!-------------------------------------
Pagination
------------------------------------->

<!-- Pagination -->
<tr if="{queues.length > 0 && ( _.get(pagination, 'next') || _.get(pagination, 'previous') ) }">
<th colspan="5">
<div class="ui right floated pagination menu" if="{queues.length > 0}">
Expand Down