diff --git a/src/apps/api/serializers/datasets.py b/src/apps/api/serializers/datasets.py index 7543afe54..127f97478 100644 --- a/src/apps/api/serializers/datasets.py +++ b/src/apps/api/serializers/datasets.py @@ -3,6 +3,7 @@ from api.mixins import DefaultUserCreateMixin from datasets.models import Data, DataGroup +from competitions.models import CompetitionCreationTaskStatus, CompetitionDump class DataSerializer(DefaultUserCreateMixin, serializers.ModelSerializer): @@ -101,13 +102,32 @@ class Meta: ) def get_competition(self, obj): - - # return competition dict with id and title if available if obj.competition: + # Submission return { "id": obj.competition.id, "title": obj.competition.title, } + else: + competition = None + try: + # Check if it is a bundle + competition = CompetitionCreationTaskStatus.objects.get(dataset=obj).resulting_competition + except CompetitionCreationTaskStatus.DoesNotExist: + competition = None + if not competition: + # Check if it is a dump + try: + competition = CompetitionDump.objects.get(dataset=obj).competition + except CompetitionDump.DoesNotExist: + competition = None + + if competition: + return { + "id": competition.id, + "title": competition.title + } + return None def get_owner_display_name(self, instance): diff --git a/src/apps/api/views/datasets.py b/src/apps/api/views/datasets.py index 2175b9dc0..1c2d10a10 100644 --- a/src/apps/api/views/datasets.py +++ b/src/apps/api/views/datasets.py @@ -40,6 +40,9 @@ def get_queryset(self): # _type = dataset if called from datasets and programs tab to filter datasets and programs is_dataset = self.request.query_params.get('_type', '') == 'dataset' + # _type = dataset if called from datasets and programs tab to filter datasets and programs + is_bundle = self.request.query_params.get('_type', '') == 'bundle' + # get queryset qs = self.queryset @@ -50,6 +53,11 @@ def get_queryset(self): # filter datasets and programs if is_dataset: qs = qs.filter(~Q(type=Data.SUBMISSION)) + qs = qs.exclude(Q(type=Data.COMPETITION_BUNDLE)) + + # filter bundles + if is_bundle: + qs = qs.filter(Q(type=Data.COMPETITION_BUNDLE)) # public filter check if is_public: @@ -58,7 +66,7 @@ def get_queryset(self): qs = qs.filter(Q(created_by=self.request.user)) # if GET is called but provided no filters, fall back to default behaviour - if (not is_submission) and (not is_dataset) and (not is_public): + if (not is_submission) and (not is_dataset) and (not is_bundle) and (not is_public): qs = self.queryset qs = qs.filter(Q(is_public=True) | Q(created_by=self.request.user)) @@ -66,7 +74,7 @@ def get_queryset(self): qs = self.queryset qs = qs.filter(Q(is_public=True) | Q(created_by=self.request.user)) - qs = qs.exclude(Q(type=Data.COMPETITION_BUNDLE) | Q(name__isnull=True)) + qs = qs.exclude(Q(name__isnull=True)) qs = qs.select_related('created_by').order_by('-created_when') diff --git a/src/apps/competitions/tasks.py b/src/apps/competitions/tasks.py index facc8041b..dfdfbaad0 100644 --- a/src/apps/competitions/tasks.py +++ b/src/apps/competitions/tasks.py @@ -408,6 +408,8 @@ def _get_error_string(error_dict): # call again, to make sure phases get sent to chahub competition.save() logger.info("Competition saved!") + status.dataset.name += f" - {competition.title}" + status.dataset.save() except CompetitionUnpackingException as e: # We want to catch well handled exceptions and display them to the user diff --git a/src/static/riot/competitions/bundle_management.tag b/src/static/riot/competitions/bundle_management.tag new file mode 100644 index 000000000..78372fee3 --- /dev/null +++ b/src/static/riot/competitions/bundle_management.tag @@ -0,0 +1,273 @@ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File NameBenchmarkSizeUploadedDelete?
{ dataset.name } + + { format_file_size(dataset.file_size) }{ timeSince(Date.parse(dataset.created_when)) } ago + + +
+ + +
+
+ No Datasets Yet! +
+ +
+ + + + + + +
\ No newline at end of file diff --git a/src/static/riot/management.tag b/src/static/riot/management.tag index 904093abf..7e0d3a549 100644 --- a/src/static/riot/management.tag +++ b/src/static/riot/management.tag @@ -4,6 +4,7 @@