Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise citation configuration #67

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 4 additions & 7 deletions bmds_ui/analysis/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from textwrap import dedent

from django.conf import settings
from django.utils.timezone import now
Expand All @@ -13,14 +12,12 @@ def get_citation() -> str:
"""
Return a citation for the software.
"""
year = now().strftime("%Y")
year = "20" + __version__[:2]
accessed = now().strftime("%B %d, %Y")
version = get_version()
uri = settings.WEBSITE_URI
return dedent(
f"""\
United States Environmental Protection Agency. ({year}). BMDS Online ({__version__}; pybmds {version.python}; bmdscore {version.dll}) [Web App]. Available from {uri}. Accessed {accessed}."""
)
application = "BMDS Desktop" if settings.IS_DESKTOP else "BMDS Online"
uri = "https://pypi.org/project/bmds-ui/" if settings.IS_DESKTOP else settings.WEBSITE_URI
return f"U.S. Environmental Protection Agency. ({year}). {application} ({__version__}; pybmds {version.python}; bmdscore {version.dll}) [Software]. Available from {uri}. Accessed {accessed}."


re_hex_color = re.compile("^#(?:[0-9a-fA-F]{3}){1,2}$")
13 changes: 13 additions & 0 deletions tests/analysis/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from bmds_ui.analysis import utils


def test_get_citation(settings):
initial = settings.IS_DESKTOP

settings.IS_DESKTOP = False
assert "BMDS Online" in utils.get_citation()

settings.IS_DESKTOP = True
assert "BMDS Desktop" in utils.get_citation()

settings.IS_DESKTOP = initial