From 081050f9b8e7bae5f53ddf39807eba567c01894e Mon Sep 17 00:00:00 2001 From: Nikolas Nyby Date: Thu, 10 Oct 2024 14:09:10 -0400 Subject: [PATCH] Add ctlsettings/sentry_js.html template partial This can be used in an application's base.html like this: ``` {% include "ctlsettings/sentry_js.html" %} ``` This should be included in the `` tag, before all other javascript includes. It relies on the SENTRY_KEY local_setting to be present. --- CHANGES.txt | 3 +++ ctlsettings/context_processors.py | 1 + ctlsettings/shared.py | 3 ++- .../templates/ctlsettings/sentry_js.html | 26 +++++++++++++++++++ ctlsettings/templates/ctlsettings/test.html | 1 + setup.py | 15 ++++++----- 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 ctlsettings/templates/ctlsettings/sentry_js.html create mode 100644 ctlsettings/templates/ctlsettings/test.html diff --git a/CHANGES.txt b/CHANGES.txt index 77ecf89..f9974a5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,9 @@ ==================== * Added a custom context processor to make settings available in templates. +* Added 'testing' environment when running tests. +* Added sentry_js.html template partial, to unify the code for this + setup. 0.3.6 (2024-10-09) ==================== diff --git a/ctlsettings/context_processors.py b/ctlsettings/context_processors.py index 607b8ac..cd43947 100644 --- a/ctlsettings/context_processors.py +++ b/ctlsettings/context_processors.py @@ -8,4 +8,5 @@ def env(request): return { 'STAGING_ENV': getattr(settings, 'STAGING_ENV', False), 'ENVIRONMENT': getattr(settings, 'ENVIRONMENT', 'development'), + 'SENTRY_KEY': getattr(settings, 'SENTRY_KEY', None), } diff --git a/ctlsettings/shared.py b/ctlsettings/shared.py index bf426fd..714945a 100644 --- a/ctlsettings/shared.py +++ b/ctlsettings/shared.py @@ -79,6 +79,7 @@ def common(**kwargs): } if 'test' in sys.argv or 'jenkins' in sys.argv: + ENVIRONMENT = 'testing' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -110,7 +111,7 @@ def common(**kwargs): { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - os.path.join(base, "templates"), + os.path.join(base, 'templates'), ], 'APP_DIRS': True, 'OPTIONS': { diff --git a/ctlsettings/templates/ctlsettings/sentry_js.html b/ctlsettings/templates/ctlsettings/sentry_js.html new file mode 100644 index 0000000..b625739 --- /dev/null +++ b/ctlsettings/templates/ctlsettings/sentry_js.html @@ -0,0 +1,26 @@ +{% if SENTRY_KEY %} + + + + + +{% endif %} diff --git a/ctlsettings/templates/ctlsettings/test.html b/ctlsettings/templates/ctlsettings/test.html new file mode 100644 index 0000000..663adb0 --- /dev/null +++ b/ctlsettings/templates/ctlsettings/test.html @@ -0,0 +1 @@ +Hi! diff --git a/setup.py b/setup.py index ecda15d..b9897a8 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ url='https://github.com/ccnmtl/ctlsettings', description='Columbia CTL common Django base settings', long_description='common settings we use across all our projects', - install_requires = [ + install_requires=[ 'django-cas-ng', 'django-debug-toolbar', 'coverage', @@ -23,9 +23,12 @@ 'gunicorn', 'django-impersonate', ], - scripts = [], - license = 'GPL-3.0-or-later', - platforms = ['any'], - package_data = {'' : ['*.*']}, - packages = ['ctlsettings'], + scripts=[], + license='GPL-3.0-or-later', + platforms=['any'], + packages=['ctlsettings', 'ctlsettings.templates'], + package_data={ + 'ctlsettings': ['*.py'], + 'ctlsettings.templates': ['*/*.html'], + }, )