From 1835b626d9610fdb8c5d5d6a5520c32f061c7c05 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Mon, 24 Feb 2025 12:34:23 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=A5=85=20warn=20when=20tex=20?= =?UTF-8?q?affiliations=20may=20be=20malformed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warn publication officer for a potentially missing TODO: block in the source file. --- scipost_django/journals/views.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scipost_django/journals/views.py b/scipost_django/journals/views.py index 35b5a353e..49a7cad64 100644 --- a/scipost_django/journals/views.py +++ b/scipost_django/journals/views.py @@ -1025,6 +1025,23 @@ def author_affiliations(request, doi_label: str) -> HttpResponse: "You do not have permission to edit this non-draft Publication" ) + if not ( + (affil_info := list(zip(*publication.tex_author_info))) + and (author_info := list(zip(*publication.tex_affiliations))) + and len(affil_info) == len(author_info) + and all(author_info[0]) # Check that author names are not empty + and all(author_info[1]) # Check that author superscripts are not empty + and all(affil_info[0]) # Check that affiliation identifiers are not empty + and all(affil_info[1]) # Check that affiliations are not empty + ): + messages.warning( + request, + "Possibly malformed information in the publication " + "if affiliations are not intentionally empty." + "Please check that the publication has authors and affiliations defined, " + 'and that they are appropriately surrounded by "%%%TODO: ____" blocks.', + ) + form = AuthorsTableOrganizationSelectForm(request.POST or None) organizations = { @@ -1068,7 +1085,6 @@ def author_affiliations(request, doi_label: str) -> HttpResponse: total_non_empty_affiliations = len( list(filter(lambda x: x is not None, organizations.values())) ) - print(total_affiliations_from_tex, total_non_empty_affiliations) if total_non_empty_affiliations != total_affiliations_from_tex: messages.warning( -- GitLab