diff --git a/templates/back_content/article.html b/templates/back_content/article.html index 9baa123..31b7575 100644 --- a/templates/back_content/article.html +++ b/templates/back_content/article.html @@ -74,68 +74,17 @@

1. Article Metadata

2. Article Authors

-
+

{% 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." %}

{% trans "Add New Author" %} - {% include "admin/elements/submit/author.html" %} + {% include "back_content/elements/add_new_author.html" %}

{% trans "If you know of an existing author, you can search for them." %}

Search Accounts for Authors
-
+

{% trans "Current Authors" %}

-
-
-
- {% csrf_token %} - - - - - - - - - - - - {% for order in article.articleauthororder_set.all %} - - - - - - - - {% empty %} - - - - {% endfor %} -
{% trans "Name" %}{% trans "Email" %}
{{ order.author.full_name }}{{ order.author.email }} - - - -
{% trans "No authors yet, add one!" %}
-
-
-
- {% csrf_token %} -

{% 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." %}

- - -
- -
-
-
+ {% include "elements/current_authors.html" %}
diff --git a/templates/back_content/elements/add_new_author.html b/templates/back_content/elements/add_new_author.html new file mode 100644 index 0000000..0b4f7d0 --- /dev/null +++ b/templates/back_content/elements/add_new_author.html @@ -0,0 +1,46 @@ +{% load foundation %} +{% load i18n %} + +
+
+
+

 {% trans "Add New Author" %}

+
+
+ + {% include "admin/elements/forms/errors.html" with form=form %} +
+ {% csrf_token %} +
+
+ {% 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 %} +
+
+ {% 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 %} +
+
+ {% include "admin/elements/forms/field.html" with field=form.frozen_email %} + {% include "admin/elements/forms/field.html" with field=form.display_email %} +
+
+
+ +
+
+
+
+
+
+
diff --git a/templates/back_content/new_article.html b/templates/back_content/new_article.html index d627bc0..ecbf6ba 100644 --- a/templates/back_content/new_article.html +++ b/templates/back_content/new_article.html @@ -20,12 +20,11 @@

New Article

-

To submit an article, click the start button below.

+

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.

{% csrf_token %} -  Submit JATS XML for Import  Import Metadata from DOI or URL
diff --git a/templates/back_content/xml_import.html b/templates/back_content/xml_import.html deleted file mode 100644 index 37d228f..0000000 --- a/templates/back_content/xml_import.html +++ /dev/null @@ -1,46 +0,0 @@ -{% extends "admin/core/base.html" %} -{% load foundation %} -{% load static %} -{% load securitytags %} -{% load files %} -{% load i18n %} - -{% block title %}Back Content Submission{% endblock %} - -{% block body %} -
-
-
-
-

Upload JATS XML File

-
-
-

The file you supply must be valid JATS XML, or this process will fail.

-
- {% csrf_token %} - - -
-
-
-
-
- {% include "elements/production/new_galley.html" %} -{% endblock %} - -{% block js %} - - - - - - {% if modal %} - {% include "elements/open_modal.html" with target=modal %} - {% endif %} - {% include "elements/datepicker.html" with target=".datepicker" %} -{% endblock %} \ No newline at end of file diff --git a/urls.py b/urls.py index 3c5978d..9b91d52 100644 --- a/urls.py +++ b/urls.py @@ -8,9 +8,6 @@ re_path(r'^$', views.index, name='bc_index'), re_path(r'^article/(?P\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[\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\d+)/galley/(?P\d+)/$', views.preview_xml_galley, diff --git a/views.py b/views.py index f1ece79..e92531e 100644 --- a/views.py +++ b/views.py @@ -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 @@ -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() @@ -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( @@ -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( @@ -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, @@ -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() @@ -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,