Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch Notify Author email field with TinyMCE #4107

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
RegistrationForm,
SectionForm,
SettingEmailForm,
SimpleTinyMCEForm,
UserCreationFormExtended,
XSLFileForm,
)
8 changes: 8 additions & 0 deletions src/core/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,3 +816,11 @@ def __init__(self, *args, **kwargs):
email_context,
setting_name,
)

class SimpleTinyMCEForm(forms.Form):
""" A one-field form for populating a TinyMCE textarea
"""

def __init__(self, field_name, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[field_name] = forms.CharField(widget=TinyMCE)
2 changes: 1 addition & 1 deletion src/journal/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def notify_author(request, article):
kwargs = {
'request': request,
'article': article,
'user_message': request.POST.get('notify_author_email', 'No message from Editor.'),
'user_message': request.POST.get('email_to_author', 'No message from Editor.'),
'section_editors': request.POST.get('section_editors', False),
'peer_reviewers': request.POST.get('peer_reviewers', False),
}
Expand Down
9 changes: 7 additions & 2 deletions src/journal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
models as core_models,
plugin_loader,
logic as core_logic,
forms as core_forms,
views as core_views,
)
from identifiers import models as id_models
Expand Down Expand Up @@ -1018,6 +1017,12 @@ def publish_article(request, article_id):
doi_data, doi = logic.get_doi_data(article)
issues = request.journal.issues
new_issue_form = issue_forms.NewIssue(journal=article.journal)
notify_author_email_form = core_forms.SimpleTinyMCEForm(
'email_to_author',
initial = {
'email_to_author': logic.get_notify_author_text(request, article)
}
)
modal = request.GET.get('m', None)
pubdate_errors = []

Expand Down Expand Up @@ -1186,7 +1191,7 @@ def publish_article(request, article_id):
'new_issue_form': new_issue_form,
'modal': modal,
'pubdate_errors': pubdate_errors,
'notify_author_text': logic.get_notify_author_text(request, article)
'notify_author_email_form': notify_author_email_form,
}

return render(request, template, context)
Expand Down
6 changes: 4 additions & 2 deletions src/templates/admin/elements/publish/author.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load foundation %}

<div class="reveal small" id="author" data-reveal data-animation-in="slide-in-up"
data-animation-out="slide-out-down">
<div class="card">
Expand All @@ -15,7 +17,7 @@ <h4><i class="fa fa-envelope-o">&nbsp;</i>Notify Author</h4>
<i>From: </i> {{ request.user.full_name }}({{ request.user.email }})<br />
<i>Subject: </i>{{ article.safe_title }} Publication
</p>
<textarea name="notify_author_email">{{ notify_author_text|linebreaksbr }}</textarea>
{{ notify_author_email_form|foundation }}

<input type="checkbox" name="section_editors" id="section_editors"><label for="section_editors" class="toggle">Notify Section Editors</label>
<br />
Expand All @@ -32,4 +34,4 @@ <h4><i class="fa fa-envelope-o">&nbsp;</i>Notify Author</h4>
<button class="close-button" data-close aria-label="Close reveal" type="button">
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>