-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #508 from dandi/doi-config-check
DOI config check
- Loading branch information
Showing
3 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.conf import settings | ||
from django.core.checks import Error, register | ||
|
||
from dandiapi.api.doi import DANDI_DOI_SETTINGS | ||
|
||
|
||
@register() | ||
def check_doi_settings(app_configs, **kwargs): | ||
any_doi_setting = any([setting is not None for setting, _ in DANDI_DOI_SETTINGS]) | ||
if not any_doi_setting: | ||
# If no DOI settings are defined, DOIs will not be created on publish. | ||
return [] | ||
errors = [] | ||
for setting, name in DANDI_DOI_SETTINGS: | ||
if setting is None: | ||
errors.append( | ||
Error( | ||
f'Setting {name} is not specified, but other DOI settings are.', | ||
hint=f'Define {name} as an environment variable.', | ||
obj=settings, | ||
) | ||
) | ||
return errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters