Skip to content

Commit

Permalink
Store full citation style keywords as a setting
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna committed Feb 19, 2025
1 parent ddeda2a commit 657ef25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions isic/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ def js_sentry(request):

def js_browser_sync(request):
return {"JS_BROWSER_SYNC": settings.ISIC_JS_BROWSER_SYNC}


def citation_styles(request):
return {"CITATION_STYLES": settings.ISIC_DATACITE_CITATION_STYLES}
2 changes: 1 addition & 1 deletion isic/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def create_doi_bundle_task(doi_id: str) -> None:
@shared_task(soft_time_limit=120, time_limit=180)
def fetch_doi_citations_task(doi_id: str) -> None:
doi = Doi.objects.get(id=doi_id)
for style in ["apa", "harvard", "mla", "chicago", "vancouver", "ieee"]:
for style in settings.ISIC_DATACITE_CITATION_STYLES:
r = requests.get(
doi.url,
headers={"Accept": f"text/x-bibliography; style={style}"},
Expand Down
11 changes: 11 additions & 0 deletions isic/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def _oauth2_pkce_required(client_id):
"isic.core.context_processors.placeholder_images",
"isic.core.context_processors.js_browser_sync",
"isic.core.context_processors.js_sentry",
"isic.core.context_processors.citation_styles",
]

# ISIC specific settings
Expand Down Expand Up @@ -211,6 +212,16 @@ def _oauth2_pkce_required(client_id):
)
ISIC_DATACITE_USERNAME: Any = None
ISIC_DATACITE_PASSWORD: Any = None
# These are the default styles with their proper names that are used by the
# DataCite GUI. The full list of supported styles is at https://citation.doi.org/.
ISIC_DATACITE_CITATION_STYLES: dict[str, str] = {
"apa": "APA",
"harvard-cite-them-right": "Harvard",
"modern-language-association": "MLA",
"vancouver": "Vancouver",
"chicago-fullnote-bibliography": "Chicago",
"ieee": "IEEE",
}
ISIC_GOOGLE_ANALYTICS_PROPERTY_IDS = [
"377090260", # ISIC Home
"360152967", # ISIC Gallery
Expand Down

0 comments on commit 657ef25

Please sign in to comment.