def send_reset_token(request, reset_token): core_reset_password_url = request.site_type.site_url( reverse( 'core_reset_password', kwargs={'token': reset_token.token}, )) context = { 'reset_token': reset_token, 'core_reset_password_url': core_reset_password_url, } log_dict = {'level': 'Info', 'types': 'Reset Token', 'target': None} if not request.journal: message = render_template.get_message_content( request, context, request.press.password_reset_text, template_is_setting=True, ) subject = 'Password Reset' else: message = render_template.get_message_content( request, context, 'password_reset', ) subject = 'subject_password_reset' notify_helpers.send_email_with_body_from_user( request, subject, reset_token.account.email, message, log_dict=log_dict, )
def get_reviewer_notification(request, article, editor, review_assignment, reminder=False): review_url = request.journal.site_url(path=reverse( 'do_review', kwargs={'assignment_id': review_assignment.id})) access_codes = setting_handler.get_setting('general', 'enable_one_click_access', request.journal).value if access_codes: review_url = "{0}?access_code={1}".format( review_url, review_assignment.access_code) email_context = { 'article': article, 'editor': editor, 'review_assignment': review_assignment, 'review_url': review_url } if reminder and reminder == 'request': return render_template.get_message_content(request, email_context, 'default_review_reminder') elif reminder and reminder == 'accepted': return render_template.get_message_content(request, email_context, 'accepted_review_reminder') else: return render_template.get_message_content(request, email_context, 'review_assignment')
def send_confirmation_link(request, new_user): context = {'user': new_user} if not request.journal: message = render_template.get_message_content( request, context, request.press.registration_text, template_is_setting=True) subject = 'Registration Confirmation' else: message = render_template.get_message_content(request, context, 'new_user_registration') subject = 'subject_new_user_registration' notify_helpers.send_slack( request, 'New registration: {0}'.format(new_user.full_name()), ['slack_admins']) log_dict = { 'level': 'Info', 'types': 'Account Confirmation', 'target': None } notify_helpers.send_email_with_body_from_user(request, subject, new_user.email, message, log_dict=log_dict)
def send_reset_token(request, reset_token): context = {'reset_token': reset_token} if not request.journal: message = render_template.get_message_content( request, context, request.press.password_reset_text, template_is_setting=True) else: message = render_template.get_message_content(request, context, 'password_reset') notify_helpers.send_email_with_body_from_user(request, 'subject_password_reset', reset_token.account.email, message)
def get_notify_proofreader(request, article, proofing_task): context = { 'article': article, 'proofing_task': proofing_task, } return render_template.get_message_content(request, context, 'notify_proofreader_assignment')
def get_complete_proofing_message(request, article): context = { 'article': article, 'proofing_assignment': article.proofingassignment, } return render_template.get_message_content(request, context, 'notify_editor_proofing_complete')
def get_copyedit_message(request, article, copyedit, template, author_review=None): """ Takes a set of variables and renders a template into a string. :param request: HttpReqest object :param article: Article object :param copyedit: CopyeditAssignment object :param template: a string matching a Setting.name from the email setting group :param author_review: an AuthorReview object relating to the CopyeditAssignment :return: """ if author_review: copyedit_review_url = request.journal.site_url(path=reverse( 'author_copyedit', args=[article.pk, author_review.pk])) else: copyedit_review_url = None copyedit_requests_url = request.journal.site_url( path=reverse('copyedit_requests')) email_context = { 'article': article, 'assignment': copyedit, 'author_review': author_review, 'author_copyedit_url': copyedit_review_url, 'copyedit_requests_url': copyedit_requests_url, } return render_template.get_message_content(request, email_context, template)
def get_production_assign_content(user, request, article, url): context = { 'user': user, 'url': url, 'article': article, } return render_template.get_message_content(request, context, 'production_assign_article')
def preprint_submission(**kwargs): """ Called by events.Event.ON_PRPINT_SUBMISSIONS, logs and emails the author and preprint editor. :param kwargs: Dictionary containing article and request objects :return: None """ request = kwargs.get('request') article = kwargs.get('article') description = '{author} has submitted a new preprint titled {title}.'.format(author=request.user.full_name(), title=article.title) log_dict = {'level': 'Info', 'action_text': description, 'types': 'Submission', 'target': article} # Send an email to the user context = {'article': article} template = request.press.preprint_submission email_text = render_template.get_message_content(request, context, template, template_is_setting=True) notify_helpers.send_email_with_body_from_user(request, 'Preprint Submission', request.user.email, email_text, log_dict=log_dict) # Send an email to the preprint editor url = request.press_base_url + reverse('preprints_manager_article', kwargs={'article_id': article.pk}) editor_email_text = 'A new preprint has been submitted to {press}: <a href="{url}">{title}</a>.'.format( press=request.press.name, url=url, title=article.title ) for editor in request.press.preprint_editors(): notify_helpers.send_email_with_body_from_user(request, 'Preprint Submission', editor.email, editor_email_text, log_dict=log_dict)
def handle_email_change(request, email_address): request.user.email = email_address request.user.is_active = False request.user.confirmation_code = uuid.uuid4() request.user.clean() request.user.save() core_confirm_account_url = request.site_type.site_url( reverse( 'core_confirm_account', kwargs={'token': request.user.confirmation_code}, )) context = { 'user': request.user, 'core_confirm_account_url': core_confirm_account_url, } message = render_template.get_message_content( request, context, 'user_email_change', ) notify_helpers.send_email_with_body_from_user( request, 'subject_user_email_change', request.user.email, message, ) logout(request)
def get_draft_email_message(request, article): email_context = { 'article': article, } return render_template.get_message_content(request, email_context, 'draft_message')
def preprint_publication(**kwargs): """ Called by events.Event.ON_PREPRINT_PUBLICATIONS handles logging and emails. :param kwargs: Dictionary containing article and request objects :return: None """ request = kwargs.get('request') article = kwargs.get('article') description = '{editor} has published a preprint titled {title}.'.format(editor=request.user.full_name(), title=article.title) log_dict = {'level': 'Info', 'action_text': description, 'types': 'Preprint Publication', 'target': article} util_models.LogEntry.add_entry('Publication', description, 'Info', request.user, request, article) # Send an email to the article owner. context = {'article': article} template = request.press.preprint_publication email_text = render_template.get_message_content(request, context, template, template_is_setting=True) notify_helpers.send_email_with_body_from_user(request, ' Preprint Submission Decision', article.owner.email, email_text, log_dict=log_dict) # Stops this notification being sent multiple times.c article.preprint_decision_notification = True article.save()
def get_notify_author_text(request, article): context = { 'article': article, } return render_template.get_message_content(request, context, 'author_publication')
def get_assignment_content(request, article, editor, assignment): email_context = { 'article': article, 'editor': editor, 'assignment': assignment, } return render_template.get_message_content(request, email_context, 'editor_assignment')
def get_notify_typesetter(request, article, proofing_task, typeset_task): context = { 'article': article, 'proofing_task': proofing_task, 'typesetter_proofing_task': typeset_task, } return render_template.get_message_content(request, context, 'notify_typesetter_proofing_changes')
def get_revision_request_content(request, article, revision): email_context = { 'article': article, 'revision': revision, } return render_template.get_message_content(request, email_context, 'request_revisions')
def send_confirmation_link(request, new_user): context = {'user': new_user} if not request.journal: message = render_template.get_message_content( request, context, request.press.registration_text, template_is_setting=True) else: message = render_template.get_message_content(request, context, 'new_user_registration') notify_helpers.send_slack( request, 'New registration: {0}'.format(new_user.full_name()), ['slack_admins']) notify_helpers.send_email_with_body_from_user( request, 'subject_new_user_registration', new_user.email, message)
def get_withdrawl_notification(request, review_assignment): email_context = { 'article': review_assignment.article, 'review_assignment': review_assignment, 'editor': request.user, } return render_template.get_message_content(request, email_context, 'review_withdrawl')
def get_copyedit_message(request, article, copyedit, template): email_context = { 'article': article, 'assignment': copyedit, } return render_template.get_message_content(request, email_context, template)
def get_copyeditor_notification(request, article, copyedit): email_context = { 'article': article, 'assignment': copyedit, } return render_template.get_message_content( request, email_context, 'copyeditor_assignment_notification')
def get_unassignment_notification(request, assignment): email_context = { 'article': assignment.article, 'assignment': assignment, 'editor': request.user, } return render_template.get_message_content(request, email_context, 'unassign_editor')
def get_draft_email_message(request, article): review_in_review_url = request.journal.site_url( path=reverse('review_draft_decision', args=[article.pk])) email_context = { 'article': article, 'review_in_review_url': review_in_review_url, } return render_template.get_message_content(request, email_context, 'draft_message')
def get_notify_proofreader(request, article, proofing_task): proofing_url = request.journal.site_url(reverse("proofing_requests")) context = { 'proofing_requests_url': proofing_url, 'article': article, 'proofing_task': proofing_task, } return render_template.get_message_content( request, context, 'notify_proofreader_assignment')
def send_email_with_body_from_setting_template(request, template, subject, to, context): notify_contents = { 'subject': subject, 'to': to, 'html': render_template.get_message_content(request, context, template), 'action': ['email'], 'request': request, } notify.notification(**notify_contents)
def handle_email_change(request, email_address): request.user.email = email_address request.user.is_active = False request.user.confirmation_code = uuid.uuid4() request.user.save() context = {'user': request.user} message = render_template.get_message_content(request, context, 'user_email_change') notify_helpers.send_email_with_body_from_user(request, 'subject_user_email_change', request.user.email, message) logout(request)
def get_decision_content(request, article, decision, author_review_url): email_context = { 'article': article, 'decision': decision, 'review_url': author_review_url, } template_name = "review_decision_{0}".format(decision) return render_template.get_message_content(request, email_context, template_name)
def get_assignment_content(request, article, editor, assignment): review_in_review_url = request.journal.site_url( reverse('review_in_review', kwargs={'article_id': article.pk})) email_context = { 'article': article, 'editor': editor, 'assignment': assignment, 'review_in_review_url': review_in_review_url, } return render_template.get_message_content(request, email_context, 'editor_assignment')
def get_notify_typesetter(request, article, proofing_task, typeset_task): proofing_url = request.journal.site_url( reverse("proofing_correction_requests")) context = { 'proofing_requests_url': proofing_url, 'article': article, 'proofing_task': proofing_task, 'typesetter_proofing_task': typeset_task, } return render_template.get_message_content( request, context, 'notify_typesetter_proofing_changes')
def get_reviewer_notification( request, article, editor, review_assignment, reminder=False, ): review_url = get_review_url(request, review_assignment) article_details = """ <b>Article Details:</b> <b>Title</b>: {article.title} <b>Section</b>: {section} Keywords: {keywords} Abstract: {article.abstract} """.format( article=article, section=article.section.name if article.section else None, keywords=", ".join(kw.word for kw in article.keywords.all()), ) email_context = { 'article': article, 'editor': editor, 'review_assignment': review_assignment, 'review_url': review_url, 'article_details': article_details, } if reminder and reminder == 'request': return render_template.get_message_content(request, email_context, 'default_review_reminder') elif reminder and reminder == 'accepted': return render_template.get_message_content(request, email_context, 'accepted_review_reminder') else: return render_template.get_message_content(request, email_context, 'review_assignment')
def get_publication_text(request, article, action): context = { 'article': article, 'request': request, 'action': action, } if article.date_declined and not article.date_published: template = request.press.preprint_decline else: template = request.press.preprint_publication email_content = render_template.get_message_content( request, context, template, template_is_setting=True) return email_content