Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
© 2024 Martin Paul Eve. [Licensed under the AGPL 3.0](LICENSE).
39 changes: 16 additions & 23 deletions logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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),
}
)

Expand Down
2 changes: 1 addition & 1 deletion migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]

Expand Down