From d83854b23f9bfccb2f3c9259344a0afe7b32bec0 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Tue, 19 Feb 2019 09:34:11 +0000 Subject: [PATCH] GH-858: Handle the progression of the submissions --- opentech/apply/funds/forms.py | 6 ++++++ opentech/apply/funds/views.py | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index 68df95604..43ae56bd8 100644 --- a/opentech/apply/funds/forms.py +++ b/opentech/apply/funds/forms.py @@ -27,6 +27,7 @@ class ProgressSubmissionForm(forms.ModelForm): class BatchProgressSubmissionForm(forms.Form): action = forms.ChoiceField(label='Take action') + submissions = forms.CharField(widget=forms.HiddenInput()) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') @@ -34,6 +35,11 @@ class BatchProgressSubmissionForm(forms.Form): choices = [(action, detail['display']) for action, detail in ACTION_MAPPING.items()] self.fields['action'].choices = choices + def clean_submissions(self): + value = self.cleaned_data['submissions'] + submission_ids = [int(submission) for submission in value.split(',')] + return ApplicationSubmission.objects.filter(id__in=submission_ids) + class ScreeningSubmissionForm(forms.ModelForm): diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index c18493bd2..099cc696f 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -27,7 +27,6 @@ from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.determinations.views import DeterminationCreateOrUpdateView from opentech.apply.review.views import ReviewContextMixin from opentech.apply.users.decorators import staff_required -from opentech.apply.users.models import User from opentech.apply.utils.views import DelegateableListView, DelegateableView, ViewDispatcher from .differ import compare @@ -133,7 +132,12 @@ class BatchProgressSubmissionView(DelegatedViewMixin, FormView): context_name = 'batch_progress_form' def form_valid(self, form): - print('wooooop') + submissions = form.cleaned_data['submissions'] + action = form.cleaned_data.get('action') + + for submission in submissions: + self.submission.perform_transition(action, self.request.user, request=self.request) + return super().form_valid(form) -- GitLab