Skip to content
Open
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
59 changes: 4 additions & 55 deletions templates/back_content/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,68 +74,17 @@ <h2 id="section-one">1. Article Metadata</h2>
<h2 id="section-two">2. Article Authors</h2>
</div>
<div class="content" data-equalizer data-equalize-on="medium">
<div class="large-7 columns" data-equalizer-watch>
<div class="large-4 columns" data-equalizer-watch>
<p>{% trans "You can add an author by clicking the button below. This will open a popup modal for you to complete their details. If you do not have a legitimate email address for this author use @journal.com as a prefix for their email address and Janeway will ignore it." %}</p>
<a href="#" data-open="author" class="small success button">{% trans "Add New Author" %}</a>
{% include "admin/elements/submit/author.html" %}
{% include "back_content/elements/add_new_author.html" %}
<p>{% trans "If you know of an existing author, you can search for them." %}</p>
<a href="{% url 'bc_article_authors' article.pk %}" class="small success button">Search Accounts for Authors</a>

</div>
<div class="large-5 columns" data-equalizer-watch>
<div class="large-8 columns" data-equalizer-watch>
<h4>{% trans "Current Authors" %}</h4>
<div class="row">
<div class="large-12 columns">
<form method="POST">
{% csrf_token %}
<table class="small scroll">
<thead>
<tr>
<th></th>
<th>{% trans "Name" %}</th>
<th>{% trans "Email" %}</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody id="sortable">
{% for order in article.articleauthororder_set.all %}
<tr id="authors-{{ order.author.pk }}">
<td><i class="fa fa-sort"></i></td>
<td>{{ order.author.full_name }}</td>
<td>{{ order.author.email }}</td>
<td>
<button name="set_main" value="{{ order.author.pk }}" class="tiny button">Set as Main</button>
</td>
<td>
<button name="remove_author" value="{{ order.author.pk }}" class="tiny alert button">Remove</button>
</td>
</tr>
{% empty %}
<tr>
<td colspan="3">{% trans "No authors yet, add one!" %}</td>
</tr>
{% endfor %}
</table>
</form>
<hr/>
<form method="POST">
{% csrf_token %}
<p>{% trans "You are required to select a main author, this author will receive the communications regarding your articles process through our systems. This does not have to be you." %}</p>
<label for="main-author">{% trans "Select main author" %}:</label>
<select class="form-control" id="main-author" name="main-author" required>
<option value="">---------</option>
{% for author in article.authors.all %}
<option value="{{ author.pk }}"
{% if article.correspondence_author.pk == author.pk %}selected{% endif %}>{{ author.full_name }}</option>
{% endfor %}
</select>
<br/>
<button class="success button pull-right" type="submit" name="save_section_2"><i
class="fa fa-check">&nbsp;</i>{% trans "Save Section 2" %}</button>
</form>
</div>
</div>
{% include "elements/current_authors.html" %}
</div>
</div>
<div class="title-area">
Expand Down
46 changes: 46 additions & 0 deletions templates/back_content/elements/add_new_author.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% load foundation %}
{% load i18n %}

<div class="reveal large" id="author" data-reveal data-animation-in="slide-in-up"
data-animation-out="slide-out-down">
<div class="card">
<div class="card-divider">
<h4><i class="fa fa-user">&nbsp;</i>{% trans "Add New Author" %}</h4>
</div>
<div class="card-section">
<button class="close-button" data-close aria-label="Close reveal" type="button">
<span aria-hidden="true">&times;</span>
</button>
{% include "admin/elements/forms/errors.html" with form=form %}
<form method="POST">
{% csrf_token %}
<div class="flex direction-column row-gap-0">
<div class="grid auto row-gap-0">
{% include "admin/elements/forms/field.html" with field=form.first_name %}
{% include "admin/elements/forms/field.html" with field=form.middle_name %}
{% include "admin/elements/forms/field.html" with field=form.last_name %}
</div>
<div class="grid auto row-gap-0">
{% include "admin/elements/forms/field.html" with field=form.name_prefix %}
{% include "admin/elements/forms/field.html" with field=form.name_suffix %}
{% include "admin/elements/forms/field.html" with field=form.is_corporate %}
</div>
<div class="grid auto row-gap-0">
{% include "admin/elements/forms/field.html" with field=form.frozen_email %}
{% include "admin/elements/forms/field.html" with field=form.display_email %}
</div>
<div class="flex wrap gap-1 items-end">
<div class="button-group">
<button
name="add_author"
class="button">
<span class="fa fa-user-plus"></span>
{% trans "Add author manually" %}
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
3 changes: 1 addition & 2 deletions templates/back_content/new_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
<h2>New Article</h2>
</div>
<div class="content">
<p>To submit an article, click the start button below.</p>
<p>To submit an article, click the start button below. You can import data from a DOI or URL below. JATS XML import is now handled in the Imports plugin.</p>
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<button type="submit" class="success button"><i class="fa fa-upload">&nbsp;</i>Start Submission
</button>
<a href="{% url 'bc_xml_import_upload' %}" class="success button"><i class="fa fa-upload">&nbsp;</i>Submit JATS XML for Import</a>
<a href="{% url 'bc_doi_import' %}" class="success button"><i class="fa fa-upload">&nbsp;</i>Import Metadata from DOI or URL</a>
</form>
</div>
Expand Down
46 changes: 0 additions & 46 deletions templates/back_content/xml_import.html

This file was deleted.

3 changes: 0 additions & 3 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
re_path(r'^$', views.index, name='bc_index'),
re_path(r'^article/(?P<article_id>\d+)/$', views.article, name='bc_article'),

re_path(r'^xml_import/$', views.xml_import_upload, name='bc_xml_import_upload'),
re_path(r'^xml_import/(?P<filename>[\w.-]{0,256})$', views.xml_import_parse, name='bc_xml_import_parse'),

re_path(r'^doi_import/$', views.doi_import, name='bc_doi_import'),

re_path(r'^article/(?P<article_id>\d+)/galley/(?P<galley_id>\d+)/$', views.preview_xml_galley,
Expand Down
121 changes: 37 additions & 84 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from django.utils import timezone
from django.http import Http404
from django.utils.translation import gettext_lazy as _
from django.db.models import Q

from submission import models, forms, logic
from core import models as core_models, files
from submission import models, forms
from submission.logic import add_new_author_from_form, get_credit_form
from core import models as core_models
from plugins.back_content import forms as bc_forms, logic as bc_logic, plugin_settings
from production import logic as prod_logic, forms as prod_forms
from identifiers import logic as id_logic
from security.decorators import editor_user_required
from utils import shared
from journal import logic as journal_logic
from events import logic as event_logic

Expand Down Expand Up @@ -59,7 +60,7 @@ def article(request, article_id):
instance=article,
additional_fields=additional_fields,
)
author_form = forms.AuthorForm()
author_form = forms.EditFrozenAuthor()
pub_form = bc_forms.PublicationInfo(instance=article)
remote_form = bc_forms.RemoteArticle(instance=article)
galley_form = prod_forms.GalleyForm()
Expand Down Expand Up @@ -134,52 +135,27 @@ def article(request, article_id):
)

if 'set_main' in request.POST:
correspondence_author = request.POST.get('set_main', None)

if correspondence_author:
author = core_models.Account.objects.get(pk=correspondence_author)
article.correspondence_author = author
article.save()
return bc_logic.return_url(
article,
section='section-two',
)

if 'add_author' in request.POST:
author_form = forms.AuthorForm(request.POST)
modal = 'author'
account = get_object_or_404(
core_models.Account,
pk=request.POST.get('set_main', None),
frozenauthor__article=article,
)
article.correspondence_author = account
article.save()
messages.add_message(
request,
messages.SUCCESS,
_('%(author_name)s (%(email)s) made correspondence author.')
% {
"author_name": account.full_name(),
"email": account.email
},
)

author = logic.check_author_exists(request.POST.get('email'))
if author:
article.authors.add(author)
messages.add_message(
request,
messages.SUCCESS,
'%s added to the article' % author.full_name(),
)
else:
if author_form.is_valid():
author = author_form.save(commit=False)
author.username = author.email
author.set_password(shared.generate_password())
author.save()
author.add_account_role(
role_slug='author',
journal=request.journal,
)
article.authors.add(author)
messages.add_message(
request,
messages.SUCCESS,
'%s added to the article' % author.full_name(),
)

models.ArticleAuthorOrder.objects.get_or_create(
article=article,
author=author,
defaults={
'order': article.next_author_sort(),
}
if request.POST and 'add_author' in request.POST:
add_new_author_from_form(
request,
article,
)

return bc_logic.return_url(
Expand All @@ -191,15 +167,11 @@ def article(request, article_id):
author_pk = request.POST.get('remove_author', None)
if author_pk:
author_to_remove = get_object_or_404(
core_models.Account,
models.FrozenAuthor,
pk=author_pk,
)
article.authors.remove(author_to_remove)
models.ArticleAuthorOrder.objects.filter(
article=article,
author=author_to_remove,
).delete()
if author_to_remove == article.correspondence_author:
author_to_remove.delete()
if author_to_remove.author == article.correspondence_author:
article.correspondence_author = None
article.save()
messages.success(
Expand Down Expand Up @@ -239,6 +211,11 @@ def article(request, article_id):
else:
return redirect(reverse('bc_index'))

authors = []
for author, credits in article.authors_and_credits().items():
credit_form = get_credit_form(request, author)
authors.append((author, credits, credit_form))

template = 'back_content/article.html'
context = {
'article': article,
Expand All @@ -250,32 +227,12 @@ def article(request, article_id):
'modal': modal,
'galley_form': galley_form,
'additional_fields': additional_fields,
'authors': authors,
}

return render(request, template, context)


@editor_user_required
def xml_import_upload(request):
if request.POST and request.FILES:
xml_file = request.FILES.get('xml_file')
filename, path = files.save_file_to_temp(xml_file)

return redirect(reverse('bc_xml_import_parse', kwargs={'filename': filename}))

template = 'back_content/xml_import.html'
context = {}

return render(request, template, context)


@editor_user_required
def xml_import_parse(request, filename):
path = files.get_temp_file_path_from_name(filename)
article = logic.import_from_jats_xml(path, request.journal)
return redirect(reverse('bc_article', kwargs={'article_id': article.pk}))


@editor_user_required
def doi_import(request):
form = bc_forms.RemoteParse()
Expand Down Expand Up @@ -391,13 +348,9 @@ def post(self, request, *args, **kwargs):
pk=author_id,
)
if author in self.get_queryset():
self.article.authors.add(author)
models.ArticleAuthorOrder.objects.get_or_create(
article=self.article,
author=author,
defaults={
'order': self.article.next_author_sort(),
}
author, created = models.FrozenAuthor.get_or_snapshot_if_email_found(
author.email,
self.article,
)
messages.success(
request,
Expand Down