diff --git a/proposals/views/proposal_views.py b/proposals/views/proposal_views.py index 67c635aa2..d8d3a4c60 100644 --- a/proposals/views/proposal_views.py +++ b/proposals/views/proposal_views.py @@ -372,6 +372,16 @@ class ProposalUpdateDataManagement(GroupRequiredMixin, generic.UpdateView): form_class = ProposalUpdateDataManagementForm group_required = settings.GROUP_SECRETARY + def form_valid(self, form): + ret = super().form_valid(form) + # Always regenerate the PDF after updating the DMP + # This is necessary, as the canonical PDF protection might already + # have kicked in if the secretary changes the documents later than + # we initially expected. + self.object.generate_pdf(force_overwrite=True) + + return ret + def get_success_url(self): """Continue to the URL specified in the 'next' POST parameter""" return reverse('reviews:detail', args=[self.object.latest_review().pk]) diff --git a/studies/views/study_views.py b/studies/views/study_views.py index 134434c6b..b2843c36b 100644 --- a/studies/views/study_views.py +++ b/studies/views/study_views.py @@ -159,6 +159,16 @@ class StudyUpdateAttachments(braces.GroupRequiredMixin, generic.UpdateView): form_class = StudyUpdateAttachmentsForm group_required = settings.GROUP_SECRETARY + def form_valid(self, form): + ret = super().form_valid(form) + # Always regenerate the PDF after updating any study documents + # This is necessary, as the canonical PDF protection might already + # have kicked in if the secretary changes the documents later than + # we initially expected. + self.object.proposal.generate_pdf(force_overwrite=True) + + return ret + def get_success_url(self): """Continue to the URL specified in the 'next' POST parameter""" return self.request.POST.get('next', '/')