diff --git a/README.md b/README.md index 14b6e3a..9cbd784 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a plugin for [Janeway](https://janeway.systems/) that enables [OA Switch When running on Janeway 1.8, the plugin will send messages to the OA Switchboard, but without CRediT or ROR support, so messages will never be delivered. For these features, please use a later version. ## Installation -1. Clone this repository into the Janeway plugins folder. +1. Clone this repository into the Janeway plugins folder as `oas` -- note that this is different from the repository name. 2. From the `src` directory run `python3 manage.py install_plugins oas` (or the [equivalent Docker command](https://janeway.readthedocs.io/en/latest/dev/installation.html)). 3. Run the Janeway command for running required migrations: `python3 manage.py migrate` 4. Restart your server (Apache, Passenger, etc) @@ -63,4 +63,4 @@ You can also inspect the status of all messages sent to the OA Switchboard by vi * The "Message" field shows the message sent. * The "Response" field shows the response from the OA Switchboard. -© 2024 Martin Paul Eve. [Licensed under the AGPL 3.0](LICENSE). \ No newline at end of file +© 2024 Martin Paul Eve. [Licensed under the AGPL 3.0](LICENSE). diff --git a/logic.py b/logic.py index 860d086..0828f4f 100644 --- a/logic.py +++ b/logic.py @@ -155,26 +155,25 @@ def build_credit(article, author): :param author: the author :return: """ - return ( - article.credit_roles_frozen[author] - if hasattr(article, "credit_roles_frozen") - else [] - ) + if hasattr(article, "authors_and_credits"): + credit_queryset = article.authors_and_credits().get(author, []) + return [str(record) for record in credit_queryset] + else: + return [] -def build_ror(author): +def build_institutions(author): """ - Build the ROR item if it exists + Build the institution item if it exists :param author: the author to build the ROR for """ - affil = author.affiliation() - - if hasattr(affil, "organization"): - org = affil.organization - else: - return "" - - return org.ror if hasattr(org, "ror") else "" + affil = author.primary_affiliation(as_object=True) + institution = { + "sourceAffiliation": str(affil), + "name": str(affil.organization.name) if affil.organization else "", + "ror": affil.organization.uri if affil.organization else "", + } + return [institution] def build_authors(article): @@ -193,14 +192,8 @@ def build_authors(article): "ORCID": author.frozen_orcid, "creditroles": build_credit(article, author), "isCorrespondingAuthor": author.is_correspondence_author, - "institutions": [ - { - "sourceaffiliation": author.affiliation(), - "name": author.affiliation(), - "ror": build_ror(author), - } - ], - "affiliation": author.affiliation(), + "institutions": build_institutions(author), + "affiliation": author.primary_affiliation(as_object=False), } ) diff --git a/migrations/0001_initial.py b/migrations/0001_initial.py index a93e169..d97b825 100644 --- a/migrations/0001_initial.py +++ b/migrations/0001_initial.py @@ -10,7 +10,7 @@ class Migration(migrations.Migration): dependencies = [ ( "submission", - "0084_remove_article_jats_article_type_and_more", + "0083_article_jats_article_type_override_and_more", ), ]