From 36eefea3d79305db240cc27f35a77e259a6740f3 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Tue, 31 Jan 2017 23:17:38 +0100 Subject: [PATCH] Fix bug in creating ThesisLink Creating a new ThesisLink didn't save the `requested_by` field, causing trouble in for example the vet view for these specific objects. --- theses/forms.py | 4 ++++ theses/views.py | 1 + 2 files changed, 5 insertions(+) diff --git a/theses/forms.py b/theses/forms.py index 5b8b8db4c..c8a890ddc 100644 --- a/theses/forms.py +++ b/theses/forms.py @@ -42,6 +42,10 @@ class VetThesisLinkForm(RequestThesisLinkForm): justification = forms.CharField(widget=forms.Textarea( attrs={'rows': 5, 'cols': 40}), label='Justification (optional)', required=False) + def __init__(self, *args, **kwargs): + super(VetThesisLinkForm, self).__init__(*args, **kwargs) + self.order_fields(['action_option', 'refusal_reason', 'justification']) + def vet_request(self, thesislink, user): if int(self.cleaned_data['action_option']) == VetThesisLinkForm.ACCEPT: thesislink.vetted = True diff --git a/theses/views.py b/theses/views.py index 34c9f035e..858e8c33d 100644 --- a/theses/views.py +++ b/theses/views.py @@ -38,6 +38,7 @@ class RequestThesisLink(CreateView): success_url = reverse_lazy('scipost:personal_page') def form_valid(self, form): + form.instance.requested_by = self.request.user.contributor messages.add_message(self.request, messages.SUCCESS, strings.acknowledge_request_thesis_link) return super(RequestThesisLink, self).form_valid(form) -- GitLab