diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index 68df956042d3523840cdc07f35363c7c1c755a89..43ae56bd8d3a20fc8f7c5080cad14ca9b67555b4 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 c18493bd2f035493c77f0de782d733a1a6922321..099cc696fa08b5c86528366a1fc255711fd88d74 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)