diff --git a/src/apps/api/views/queues.py b/src/apps/api/views/queues.py index 4a5870c64..db96188c6 100644 --- a/src/apps/api/views/queues.py +++ b/src/apps/api/views/queues.py @@ -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() diff --git a/src/static/riot/competitions/editor/_competition_details.tag b/src/static/riot/competitions/editor/_competition_details.tag index a91445998..6ed3f5427 100644 --- a/src/static/riot/competitions/editor/_competition_details.tag +++ b/src/static/riot/competitions/editor/_competition_details.tag @@ -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, diff --git a/src/static/riot/queues/management.tag b/src/static/riot/queues/management.tag index 062693bc2..fafb43ede 100644 --- a/src/static/riot/queues/management.tag +++ b/src/static/riot/queues/management.tag @@ -69,9 +69,8 @@
- + +