Skip to content

Commit

Permalink
Allow multiple jobs submission
Browse files Browse the repository at this point in the history
  • Loading branch information
emilmelnikov committed Jan 29, 2020
1 parent f418a1e commit dcad600
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 9 additions & 3 deletions batch/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions cloud_ilastik/templates/batch/project_new_job.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
<legend>Select datasets for batch job submission</legend>
{% for dataset in dataset_list %}
<div class="form-check">
<input type="radio"
<input type="checkbox"
id="dataset-{{ dataset.pk }}"
name="dataset"
value="{{ dataset.pk }}"
name="dataset-{{ dataset.pk }}"
class="form-check-input">
<label for="dataset-{{ dataset.pk }}" class="form-check-label">
<a href="{% url 'datasets:detail' dataset.pk %}">{{ dataset.name }}</a>
Expand Down

0 comments on commit dcad600

Please sign in to comment.