From f1559f16ff711c22ca443f89fd0e246d7aac17e1 Mon Sep 17 00:00:00 2001
From: Geert Kapteijns <ghkapteijns@gmail.com>
Date: Sun, 14 May 2017 12:21:16 +0200
Subject: [PATCH] Add messages upon success on query and request commentary
 forms.

---
 commentaries/forms.py |  1 -
 commentaries/views.py | 10 ++++++++++
 strings/__init__.py   |  2 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/commentaries/forms.py b/commentaries/forms.py
index 8eabe7a28..68796e3f4 100644
--- a/commentaries/forms.py
+++ b/commentaries/forms.py
@@ -31,7 +31,6 @@ class DOIToQueryForm(forms.Form):
 
         return input_doi
 
-
     def request_published_article_form_prefill_data(self):
         additional_form_data = {'pub_DOI': self.cleaned_data['doi']}
         return {**self.crossref_data, **additional_form_data}
diff --git a/commentaries/views.py b/commentaries/views.py
index 61dce5040..aace26ae6 100644
--- a/commentaries/views.py
+++ b/commentaries/views.py
@@ -43,6 +43,10 @@ class RequestPublishedArticle(CreateView):
         context['doi_query_form'] = DOIToQueryForm()
         return context
 
+    def form_valid(self, form):
+        messages.success(self.request, strings.acknowledge_request_commentary)
+        return super(RequestArxivPreprint, self).form_valid(form)
+
 
 @method_decorator(permission_required(
     'scipost.can_request_commentary_pages', raise_exception=True), name='dispatch')
@@ -56,6 +60,10 @@ class RequestArxivPreprint(CreateView):
         context['arxiv_query_form'] = ArxivQueryForm()
         return context
 
+    def form_valid(self, form):
+        messages.success(self.request, strings.acknowledge_request_commentary)
+        return super(RequestArxivPreprint, self).form_valid(form)
+
 
 @permission_required('scipost.can_request_commentary_pages', raise_exception=True)
 def prefill_using_DOI(request):
@@ -65,6 +73,7 @@ def prefill_using_DOI(request):
         if doi_query_form.is_valid():
             prefill_data = doi_query_form.request_published_article_form_prefill_data()
             form = RequestPublishedArticleForm(initial=prefill_data)
+            messages.success(request, strings.acknowledge_doi_query)
         else:
             form = RequestPublishedArticleForm()
 
@@ -84,6 +93,7 @@ def prefill_using_arxiv_identifier(request):
         if arxiv_query_form.is_valid():
             prefill_data = arxiv_query_form.request_arxiv_preprint_form_prefill_data()
             form = RequestArxivPreprintForm(initial=prefill_data)
+            messages.success(request, strings.acknowledge_arxiv_query)
         else:
             form = RequestArxivPreprintForm()
 
diff --git a/strings/__init__.py b/strings/__init__.py
index acb0df6ce..6e35b4e9e 100644
--- a/strings/__init__.py
+++ b/strings/__init__.py
@@ -10,6 +10,8 @@ acknowledge_request_commentary = (
 acknowledge_submit_comment = (
     "Thank you for contributing a Comment. It will soon be vetted by an Editor."
 )
+acknowledge_doi_query = "Crossref query by DOI successful."
+acknowledge_arxiv_query = "Arxiv query successful."
 
 # Arxiv response is not valid
 arxiv_caller_errormessages = {
-- 
GitLab