Skip to content
Open
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
3 changes: 2 additions & 1 deletion plugin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
DATACITE_PASSWORD = ''
DATACITE_PREFIX = ''
DATACITE_API_URL = 'https://api.datacite.org/dois'
DATACITE_API_TEST_URL = 'https://api.test.datacite.org/dois'
JOURNAL_PREFIX = True
MINT_AUTOMATICALLY = False
REDEPOSIT_BUTTON = False

if settings.DEBUG:
DATACITE_API_URL = 'https://api.test.datacite.org/dois' # Use test in debug mode.
DATACITE_API_URL = DATACITE_API_TEST_URL # Use test in debug mode.


class DatacitePlugin(plugins.Plugin):
Expand Down
7 changes: 6 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from plugins.datacite import plugin_settings
from identifiers import models as ident_models
from utils import setting_handler
from journal.models import Journal


def prep_data(article, doi, event=None):
Expand Down Expand Up @@ -130,7 +131,11 @@ def mint_datacite_doi(article, doi, event=None):

if event == 'publish' and article.get_doi():
# The DOI will exists and we should use a PUT command
url = '{}/{}'.format(plugin_settings.DATACITE_API_URL, article.get_doi())
api_url = plugin_settings.DATACITE_API_URL
if hasattr(article.journal, "status"):
if article.journal.status == Journal.PublishingStatus.TEST:
api_url = plugin_settings.DATACITE_API_TEST_URL
Comment on lines +134 to +137
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this overrides the behaviour of the settings, I think we should put a warning on the template as well, to inform the user ("journal in test mode: Will use Datacite test API) type deal.

url = '{}/{}'.format(api_url, article.get_doi())
response = requests.put(
url=url,
json=prep_data(article, doi, event),
Expand Down