From 310200b09e7723910ce1b140f47324502122ece0 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sat, 23 Jan 2016 21:58:43 +0100 Subject: [PATCH] Finish email functionality for registration, commentaries and comments --- .../templates/commentaries/commentary_detail.html | 2 +- commentaries/views.py | 4 ++-- comments/views.py | 15 ++++++++------- .../templates/submissions/submission_detail.html | 1 + submissions/views.py | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/commentaries/templates/commentaries/commentary_detail.html b/commentaries/templates/commentaries/commentary_detail.html index 59acc3557..dbfd7b14f 100644 --- a/commentaries/templates/commentaries/commentary_detail.html +++ b/commentaries/templates/commentaries/commentary_detail.html @@ -265,7 +265,7 @@ <h3>Write your comment here:</h3> {{ form.comment_text }} <input type="submit" value="Submit your Comment"> - <p id="goodCommenter"><i>(by clicking on Submit, the commenter certifies that he/she has read the publication fully and carefully before writing this Comment)</i></p> + <p id="goodCommenter"><i>By clicking on Submit, the commenter certifies that he/she has read the publication fully and carefully before writing this Comment, and that all sources used are duly referenced and cited. Failure to do so will lead to exclusion from the portal.</i></p> </div> </div> </form> diff --git a/commentaries/views.py b/commentaries/views.py index 47ed8b810..ddd141d57 100644 --- a/commentaries/views.py +++ b/commentaries/views.py @@ -53,11 +53,11 @@ def request_commentary(request): form = AuthenticationForm() return render(request, 'scipost/login.html', {'form': form}) + def request_commentary_ack(request): return render(request, 'commentaries/request_commentary_ack.html') - def vet_commentary_requests(request): contributor = Contributor.objects.get(user=request.user) commentary_to_vet = Commentary.objects.filter(vetted=False).first() # only handle one at a time @@ -67,6 +67,7 @@ def vet_commentary_requests(request): return render(request, 'commentaries/vet_commentary_requests.html', context) return render (request, 'commentaries/no_commentary_req_to_vet.html') + def no_commentary_req_to_vet(request): return render (request, 'commentaries/no_commentary_req_to_vet.html') @@ -106,7 +107,6 @@ def vet_commentary_request_ack(request, commentary_id): return render(request, 'commentaries/vet_commentary_request_ack.html', context) - def commentaries(request): if request.method == 'POST': form = CommentarySearchForm(request.POST) diff --git a/comments/views.py b/comments/views.py index cba73c4a0..c193bd753 100644 --- a/comments/views.py +++ b/comments/views.py @@ -13,13 +13,13 @@ from django.db.models import Avg from .models import * from .forms import * +from scipost.models import title_dict def comment_submission_ack(request): return render(request, 'comments/comment_submission_ack.html') - def vet_submitted_comments(request): contributor = Contributor.objects.get(user=request.user) comment_to_vet = Comment.objects.filter(status=0).first() # only handle one at a time @@ -29,6 +29,7 @@ def vet_submitted_comments(request): return(render(request, 'comments/vet_submitted_comments.html', context)) return render (request, 'comments/no_comment_to_vet.html') + def no_comment_to_vet(request): return render (request, 'comments/no_comment_to_vet.html') @@ -42,19 +43,19 @@ def vet_submitted_comment_ack(request, comment_id): # accept the comment as is comment.status = 1 comment.save() - email_text = 'Dear ' + comment.author.title + ' ' + comment.author.user.last_name + ', \n\nThe Comment you have submitted, concerning publication with title ' + email_text = 'Dear ' + title_dict[comment.author.title] + ' ' + comment.author.user.last_name + ', \n\nThe Comment you have submitted, concerning publication with title ' if comment.commentary is not None: email_text += comment.commentary.pub_title + ' by ' + comment.commentary.author_list elif comment.submission is not None: email_text += comment.submission.title + ' by ' + comment.submission.author_list email_text += ', has been accepted and published online.' + '\n\nThank you for your contribution, \nThe SciPost Team.' - emailmessage = EmailMessage('SciPost Comment published', email_text, 'noreply@scipost.org', ['jscaux@gmail.com'], reply_to=['J.S.Caux@uva.nl']) + emailmessage = EmailMessage('SciPost Comment published', email_text, 'comments@scipost.org', [comment.author.user.email, 'comments@scipost.org'], reply_to=['comments@scipost.org']) emailmessage.send(fail_silently=False) elif form.cleaned_data['action_option'] == '2': # the comment request is simply rejected comment.status = form.cleaned_data['refusal_reason'] comment.save() - email_text = 'The Comment you have submitted, concerning publication with title ' + email_text = 'Dear ' + title_dict[comment.author.title] + ' ' + comment.author.user.last_name + ', \n\nThe Comment you have submitted, concerning publication with title ' if comment.commentary is not None: email_text += comment.commentary.pub_title + ' by ' + comment.commentary.author_list elif comment.submission is not None: @@ -62,7 +63,7 @@ def vet_submitted_comment_ack(request, comment_id): email_text += ', has been rejected for the following reason:' + form.cleaned_data['refusal_reason'] + '.\n\nThank you for your contribution, \nThe SciPost Team.' if form.cleaned_data['email_response_field']: email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] - emailmessage = EmailMessage('SciPost Comment rejected', email_text, 'noreply@scipost.org', ['jscaux@gmail.com'], reply_to=['J.S.Caux@uva.nl']) + emailmessage = EmailMessage('SciPost Comment rejected', email_text, 'comments@scipost.org', [comment.author.user.email, 'comments@scipost.org'], reply_to=['comments@scipost.org']) emailmessage.send(fail_silently=False) context = {} @@ -176,7 +177,7 @@ def vet_author_reply_ack(request, reply_id): elif reply.submission is not None: email_text += reply.submission.title + ' by ' + reply.submission.author_list email_text += ', has been accepted and published online.' + '\n\nThank you for your contribution, \nThe SciPost Team.' - emailmessage = EmailMessage('SciPost Author Reply published', email_text, 'noreply@scipost.org', ['jscaux@gmail.com'], reply_to=['J.S.Caux@uva.nl']) + emailmessage = EmailMessage('SciPost Author Reply published', email_text, 'comments@scipost.org', [reply.author.user.email, 'comments@scipost.org'], reply_to=['comments@scipost.org']) emailmessage.send(fail_silently=False) elif form.cleaned_data['action_option'] == '2': # the reply is simply rejected @@ -190,7 +191,7 @@ def vet_author_reply_ack(request, reply_id): email_text += ', has been rejected for the following reason:' + form.cleaned_data['refusal_reason'] + '.\n\nThank you for your contribution, \nThe SciPost Team.' if form.cleaned_data['email_response_field']: email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] - emailmessage = EmailMessage('SciPost AuthorReply rejected', email_text, 'noreply@scipost.org', ['jscaux@gmail.com'], reply_to=['J.S.Caux@uva.nl']) + emailmessage = EmailMessage('SciPost AuthorReply rejected', email_text, 'comments@scipost.org', [reply.author.user.email, 'comments@scipost.org'], reply_to=['comments@scipost.org']) emailmessage.send(fail_silently=False) context = {} diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html index e67fb77b7..735ed8f49 100644 --- a/submissions/templates/submissions/submission_detail.html +++ b/submissions/templates/submissions/submission_detail.html @@ -413,6 +413,7 @@ <h3>Write your comment here:</h3> {{ form.comment_text }} <input type="submit" value="Submit your Comment"> + <p id="goodCommenter"><i>By clicking on Submit, the commenter certifies that he/she has read the publication fully and carefully before writing this Comment, and that all sources used are duly referenced and cited. Failure to do so will lead to exclusion from the portal.</i></p> </div> </div> </form> diff --git a/submissions/views.py b/submissions/views.py index b917ecef1..1db8f9c58 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -13,7 +13,7 @@ from .models import * from .forms import * from comments.models import Comment, AuthorReply -from scipost.models import Contributor +from scipost.models import Contributor, title_dict from submissions.models import Submission from comments.forms import CommentForm -- GitLab