From 6ada31bcafbadfd5d11a4ded51e52a55b3636247 Mon Sep 17 00:00:00 2001
From: SwoopDoable <swoop-doable.0v@icloud.com>
Date: Mon, 12 Aug 2024 17:16:46 +0200
Subject: [PATCH] Remove previous author ordering code

---
 .../journals/_publication_actions.html        |  3 ---
 .../journals/_publication_preparation.html    |  1 -
 scipost_django/journals/urls/general.py       |  7 +-----
 scipost_django/journals/views.py              | 22 -------------------
 4 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/scipost_django/journals/templates/journals/_publication_actions.html b/scipost_django/journals/templates/journals/_publication_actions.html
index 93aec8fa1..bd275f256 100644
--- a/scipost_django/journals/templates/journals/_publication_actions.html
+++ b/scipost_django/journals/templates/journals/_publication_actions.html
@@ -6,9 +6,6 @@
       <li>
         <a href="{% url 'journals:add_author' doi_label=publication.doi_label %}">Add a missing author</a>
       </li>
-      <li>
-        <a href="{% url 'journals:update_author_ordering' doi_label=publication.doi_label %}">Update author ordering</a>
-      </li>
       <li>
         <a href="{% url 'journals:author_affiliations' doi_label=publication.doi_label %}">Manage author affiliations</a>
       </li>
diff --git a/scipost_django/journals/templates/journals/_publication_preparation.html b/scipost_django/journals/templates/journals/_publication_preparation.html
index 4cd448b93..1a0983f27 100644
--- a/scipost_django/journals/templates/journals/_publication_preparation.html
+++ b/scipost_django/journals/templates/journals/_publication_preparation.html
@@ -4,7 +4,6 @@
 <ul>
   <li><span class="text-success">{% include 'bi/check-square-fill.html' %}</span><a href="{% url 'journals:update_publication' publication.doi_label %}">Update Publication object</a></li>
   <li>{% if publication|has_all_author_relations %}<span class="text-success">{% include 'bi/check-square-fill.html' %}</span>{% else %}{% include 'bi/square.html' %}{% endif %}<a href="{% url 'journals:add_author' publication.doi_label %}">Create all author relations</a></li>
-  <li>{% if publication|authors_in_right_order %}<span class="text-success">{% include 'bi/check-square-fill.html' %}</span>{% else %}{% include 'bi/square.html' %}{% endif %}<a href="{% url 'journals:update_author_ordering' doi_label=publication.doi_label %}">Update Author ordering</a></li>
   <li>{% if publication|author_affiliations_complete %}<span class="text-success">{% include 'bi/check-square-fill.html' %}</span>{% else %}{% include 'bi/square.html' %}{% endif %}<a href="{% url 'journals:author_affiliations' doi_label=publication.doi_label %}">Manage Author Affiliations</a></li>
   <li>{% if publication.has_abstract_jats %}<span class="text-success">{% include 'bi/check-square-fill.html' %}</span>{% else %}{% include 'bi/square.html' %}{% endif %}<a href="{% url 'journals:abstract_jats' publication.doi_label %}">Create/update abstract (JATS version)</a></li>
   <li>{% if publication.has_citation_list %}<span class="text-success">{% include 'bi/check-square-fill.html' %}</span>{% else %}{% include 'bi/square.html' %}{% endif %}<a href="{% url 'journals:create_citation_list_metadata' publication.doi_label %}">Create/update citation metadata</a></li>
diff --git a/scipost_django/journals/urls/general.py b/scipost_django/journals/urls/general.py
index d77134e94..2426b96fd 100644
--- a/scipost_django/journals/urls/general.py
+++ b/scipost_django/journals/urls/general.py
@@ -79,11 +79,6 @@ urlpatterns = [
         journals_views.DraftPublicationApprovalView.as_view(),
         name="send_publication_for_approval",
     ),
-    path(
-        "admin/publications/<publication_doi_label:doi_label>/authors",
-        journals_views.publication_authors_ordering,
-        name="update_author_ordering",
-    ),
     path(
         "admin/publications/<publication_doi_label:doi_label>/grants",
         journals_views.PublicationGrantsView.as_view(),
@@ -101,7 +96,7 @@ urlpatterns = [
         name="add_author",
     ),
     path(
-        "admin/<publication_doi_label:doi_label>/authors/reset_authors",
+        "admin/<publication_doi_label:doi_label>/authors/reset",
         journals_views.reset_authors,
         name="reset_authors",
     ),
diff --git a/scipost_django/journals/views.py b/scipost_django/journals/views.py
index a8132282b..da564a497 100644
--- a/scipost_django/journals/views.py
+++ b/scipost_django/journals/views.py
@@ -659,28 +659,6 @@ class PublicationGrantsRemovalView(PermissionsMixin, DetailView):
             reverse("journals:update_grants", args=(self.object.doi_label,))
         )
 
-
-@permission_required("scipost.can_draft_publication", raise_exception=True)
-def publication_authors_ordering(request, doi_label):
-    publication = get_object_or_404(Publication, doi_label=doi_label)
-    if not publication.is_draft and not request.user.has_perm(
-        "scipost.can_publish_accepted_submission"
-    ):
-        raise Http404("You do not have permission to edit this non-draft Publication")
-    formset = PublicationAuthorOrderingFormSet(
-        request.POST or None, queryset=publication.authors.order_by("order")
-    )
-    if formset.is_valid():
-        formset.save()
-        messages.success(request, "Author ordering updated")
-        return redirect(publication.get_absolute_url())
-    context = {
-        "formset": formset,
-        "publication": publication,
-    }
-    return render(request, "journals/publication_authors_form.html", context)
-
-
 class DraftPublicationCreateView(PermissionsMixin, CreateView):
     """
     Create a draft of a Publication.
-- 
GitLab