Skip to content

Commit

Permalink
Add setting for publishing DOIs
Browse files Browse the repository at this point in the history
The default status for new DOIs is "draft". We want to allow django to
make new DOIs with status "findable", but only in production.
  • Loading branch information
dchiquito committed Jul 29, 2021
1 parent de8104f commit 42cbaca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dandiapi/api/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ def _generate_doi_data(version: Version):
os.environ['DANDI_ALLOW_LOCALHOST_URLS'] = 'True'
from dandischema.datacite import to_datacite

publish = settings.DANDI_DOI_PUBLISH
prefix = settings.DANDI_DOI_API_PREFIX or '10.80507'
dandiset_id = version.dandiset.identifier
version_id = version.version
doi = f'{prefix}/dandi.{dandiset_id}/{version_id}'
metadata = version.metadata.metadata
metadata['doi'] = doi
return (doi, to_datacite(metadata))
return (doi, to_datacite(metadata, publish=publish))


def create_doi(version: Version) -> str:
Expand Down
1 change: 1 addition & 0 deletions dandiapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def before_binding(configuration: Type[ComposedConfiguration]):
DANDI_DOI_API_USER = values.Value(environ=True)
DANDI_DOI_API_PASSWORD = values.Value(environ=True)
DANDI_DOI_API_PREFIX = values.Value(environ=True)
DANDI_DOI_PUBLISH = values.BooleanValue(environ=True, default=False)

# The CloudAMQP connection was dying, using the heartbeat should keep it alive
CELERY_BROKER_HEARTBEAT = 20
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
install_requires=[
'celery',
'dandischema>=0.3.1',
'dandischema>=0.3.2',
'django>=3.1.2',
'django-admin-display',
'django-allauth',
Expand Down

0 comments on commit 42cbaca

Please sign in to comment.