diff --git a/batch/views.py b/batch/views.py index 472d9f1..ea43526 100644 --- a/batch/views.py +++ b/batch/views.py @@ -53,11 +53,17 @@ def post(self, request, *args, **kwargs): project = self.get_object() try: - dataset = self._compatible_datasets.get(pk=int(self.request.POST["dataset"])) - except (KeyError, ValueError, datasets_models.Dataset.DoesNotExist): + prefix = "dataset-" + # Is it an error if there are no datasets, or some datasets in the request are not in the compatible set? + datasets = self._compatible_datasets.filter( + id__in=(int(k[len(prefix):]) for k in self.request.POST if k.startswith(prefix)) + ) + except (KeyError, ValueError): return HttpResponse(status=400) - models.Job.objects.create(project=project, owner=self.request.user, raw_data=dataset) + models.Job.objects.bulk_create( + models.Job(project=project, owner=self.request.user, raw_data=dataset) for dataset in datasets + ) return HttpResponseRedirect(urls.reverse("batch:project-detail", args=[project.pk])) @property diff --git a/cloud_ilastik/templates/batch/project_new_job.html b/cloud_ilastik/templates/batch/project_new_job.html index 758c3af..76b7b46 100644 --- a/cloud_ilastik/templates/batch/project_new_job.html +++ b/cloud_ilastik/templates/batch/project_new_job.html @@ -7,10 +7,9 @@ {% for dataset in dataset_list %}