From 6280ab13839c951e88c3c1d57d57f0204ba70721 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Thu, 11 May 2023 18:35:48 +0500 Subject: [PATCH 1/2] queue added to competition while unpacking from YAML --- .../competitions/unpackers/base_unpacker.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/apps/competitions/unpackers/base_unpacker.py b/src/apps/competitions/unpackers/base_unpacker.py index 8a10dc77f..2b1ac3a06 100644 --- a/src/apps/competitions/unpackers/base_unpacker.py +++ b/src/apps/competitions/unpackers/base_unpacker.py @@ -201,15 +201,24 @@ def _unpack_image(self): def _unpack_queue(self): # Get Queue by vhost/uuid. If instance not returned, or we don't have access don't set it! - vhost = self.competition_yaml.get('queue') - if vhost: + queue_name = self.competition_yaml.get('queue') + if queue_name: try: - queue = Queue.objects.get(vhost=vhost) + queue = Queue.objects.get(name=queue_name) if not queue.is_public: all_queue_organizer_names = queue.organizers.all().values_list('username', flat=True) if queue.owner != self.creator and self.creator.username not in all_queue_organizer_names: raise CompetitionUnpackingException("You do not have access to the specified queue!") - self.competition['queue'] = queue.id + self.competition['queue'] = { + 'name': queue.name, + 'vhost': queue.vhost, + 'is_public': queue.is_public, + 'owner': queue.owner, + 'organizers': queue.organizers, + 'broker_url': queue.broker_url, + 'created_when': queue.broker_url, + 'id': queue.id, + } except Queue.DoesNotExist: raise CompetitionUnpackingException("The specified Queue does not exist!") From 1c318d6871a031f89b127cdaf15721fc72dbd942 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Thu, 11 May 2023 19:41:16 +0500 Subject: [PATCH 2/2] queue name changed to vhost --- src/apps/competitions/unpackers/base_unpacker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/competitions/unpackers/base_unpacker.py b/src/apps/competitions/unpackers/base_unpacker.py index 2b1ac3a06..281069ca1 100644 --- a/src/apps/competitions/unpackers/base_unpacker.py +++ b/src/apps/competitions/unpackers/base_unpacker.py @@ -201,10 +201,10 @@ def _unpack_image(self): def _unpack_queue(self): # Get Queue by vhost/uuid. If instance not returned, or we don't have access don't set it! - queue_name = self.competition_yaml.get('queue') - if queue_name: + vhost = self.competition_yaml.get('queue') + if vhost: try: - queue = Queue.objects.get(name=queue_name) + queue = Queue.objects.get(vhost=vhost) if not queue.is_public: all_queue_organizer_names = queue.organizers.all().values_list('username', flat=True) if queue.owner != self.creator and self.creator.username not in all_queue_organizer_names: