apis-acdhch-default-settings 1.7.0__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import re
3
3
  from typing import Any, Dict
4
+ from pathlib import Path
4
5
 
5
6
  from django.core.management.utils import get_random_secret_key
6
7
  import dj_database_url
@@ -25,10 +26,7 @@ if os.environ.get("SENTRY_DSN"):
25
26
 
26
27
  SECRET_KEY = os.environ.get("SECRET_KEY", get_random_secret_key())
27
28
 
28
- # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
29
- BASE_DIR = os.path.dirname(
30
- os.path.dirname(os.path.abspath(os.path.join(__file__, "../")))
31
- )
29
+ BASE_DIR = Path(__file__).resolve().parent.parent
32
30
 
33
31
  # Application definition
34
32
  # put apis_override_select2js at the beginning of the list
@@ -43,6 +41,7 @@ INSTALLED_APPS = [
43
41
  "django.contrib.sessions",
44
42
  "django.contrib.messages",
45
43
  "django.contrib.staticfiles",
44
+ "django_removals",
46
45
  "crispy_forms",
47
46
  "crispy_bootstrap4",
48
47
  "django_filters",
@@ -50,7 +49,6 @@ INSTALLED_APPS = [
50
49
  "rest_framework",
51
50
  "apis_ontology",
52
51
  "apis_acdhch_default_settings",
53
- "apis_core.apis_relations",
54
52
  "apis_core.apis_entities",
55
53
  "apis_core.apis_metainfo",
56
54
  "apis_core.apis_vocabularies",
@@ -82,20 +80,11 @@ CSP_DEFAULT_SRC = (
82
80
  "'unsafe-inline'",
83
81
  "cdnjs.cloudflare.com",
84
82
  "cdn.jsdelivr.net",
85
- "fonts.googleapis.com",
86
83
  "ajax.googleapis.com",
87
- "cdn.rawgit.com",
88
84
  "*.acdh.oeaw.ac.at",
89
85
  "unpkg.com",
90
- "fonts.gstatic.com",
91
- "cdn.datatables.net",
92
- "code.highcharts.com",
93
- "*.acdh-dev.oeaw.ac.at",
94
- "*.acdh.oeaw.ac.at",
95
- "openstreetmap.org",
96
86
  "*.openstreetmap.org",
97
87
  )
98
- CSP_FRAME_SRC = ("sennierer.github.io",)
99
88
 
100
89
  # django-crispy-forms settings
101
90
  # https://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
@@ -134,6 +123,8 @@ MIDDLEWARE = [
134
123
  "django.middleware.clickjacking.XFrameOptionsMiddleware",
135
124
  "csp.middleware.CSPMiddleware",
136
125
  "crum.CurrentRequestUserMiddleware",
126
+ # this is used by the apis_core.history module:
127
+ "simple_history.middleware.HistoryRequestMiddleware",
137
128
  ]
138
129
 
139
130
  # https://docs.djangoproject.com/en/stable/ref/settings/#root-urlconf
@@ -164,13 +155,15 @@ AUTH_PASSWORD_VALIDATORS = [
164
155
  {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
165
156
  ]
166
157
 
158
+ # Default primary key field type
159
+ # https://docs.djangoproject.com/en/stable/ref/settings/#default-auto-field
160
+ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
167
161
 
168
162
  # Internationalization
169
163
  # https://docs.djangoproject.com/en/stable/topics/i18n/
170
164
  LANGUAGE_CODE = "en"
171
165
  TIME_ZONE = "UTC"
172
166
  USE_I18N = True
173
- USE_L10N = True
174
167
  USE_TZ = True
175
168
 
176
169
  # Static files (CSS, JavaScript, Images)
@@ -5,7 +5,7 @@ from django.contrib import admin
5
5
  from django.urls import path
6
6
  from django.views.generic import TemplateView
7
7
 
8
- from apis_acdhch_default_settings import utils
8
+ from apis_acdhch_default_settings.views import Imprint
9
9
 
10
10
  from apis_core.apis_entities.api_views import GetEntityGeneric
11
11
 
@@ -25,4 +25,4 @@ if "apis_bibsonomy" in settings.INSTALLED_APPS:
25
25
  )
26
26
 
27
27
  urlpatterns.append(path("", TemplateView.as_view(template_name="base.html")))
28
- urlpatterns.append(path("imprint", TemplateView.as_view(template_name="imprint.html", extra_context={"imprint": utils.get_imprint()}), name="imprint"))
28
+ urlpatterns.append(path("imprint", Imprint.as_view(), name="imprint"))
@@ -0,0 +1,29 @@
1
+ import requests
2
+ import os
3
+ from django.views.generic import TemplateView
4
+ from django.views.decorators.cache import cache_page
5
+ from django.utils.decorators import method_decorator
6
+
7
+ from django.conf import settings
8
+
9
+
10
+ @method_decorator(cache_page(60 * 5), name='dispatch')
11
+ class Imprint(TemplateView):
12
+ template_name = "imprint.html"
13
+
14
+ def get_context_data(self) -> str:
15
+ ctx = super().get_context_data()
16
+ base_url = getattr(settings, "ACDH_IMPRINT_URL", "https://imprint.acdh.oeaw.ac.at/")
17
+ redmine_id = getattr(settings, "REDMINE_ID", os.getenv("SERVICE_ID", ""))
18
+
19
+ r = requests.get(f"{base_url}{redmine_id}")
20
+
21
+ if r and redmine_id:
22
+ ctx["imprint"] = r.text
23
+ else:
24
+ ctx["imprint"] = """
25
+ One of our services is currently not available. Please try it later or write
26
+ an email to acdh@oeaw.ac.at; if you are service provider, make sure that you
27
+ provided ACDH_IMPRINT_URL and REDMINE_ID.
28
+ """
29
+ return ctx
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: apis-acdhch-default-settings
3
- Version: 1.7.0
3
+ Version: 2.0.0
4
4
  Summary: Default settings for APIS instances at the ACDH-CH
5
5
  License: MIT
6
6
  Author: Birger Schacht
@@ -15,6 +15,7 @@ Requires-Dist: dj-database-url (>=2.0.0,<3.0.0)
15
15
  Requires-Dist: django-allow-cidr (>=0.6.0,<0.7.0)
16
16
  Requires-Dist: django-auth-ldap (>=4.6.0,<5.0.0)
17
17
  Requires-Dist: django-csp (>=3.7,<4.0)
18
+ Requires-Dist: django-removals (>=1.0.5,<2.0.0)
18
19
  Requires-Dist: opentelemetry-distro
19
20
  Requires-Dist: opentelemetry-exporter-otlp
20
21
  Requires-Dist: opentelemetry-instrumentation-asgi
@@ -0,0 +1,11 @@
1
+ apis_acdhch_default_settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ apis_acdhch_default_settings/ldapauth.py,sha256=P1NDgWG2Pp4JzqoETq3VDC3DtECoEIXWBA3Lzn6CUIA,423
3
+ apis_acdhch_default_settings/settings.py,sha256=gpLwPiHHsrdyK5lhje3ftr-VbMz06k020x6ldDR2NfQ,9065
4
+ apis_acdhch_default_settings/templates/base.html,sha256=c3QhbTzJLzCii-Ck5x0wftHx_Y0aFhPfJUhUVknz_Ks,217
5
+ apis_acdhch_default_settings/templates/imprint.html,sha256=juOqq6yzT9FMhjPjhbofDPZxRNO2fhOLlS478reFjE0,254
6
+ apis_acdhch_default_settings/urls.py,sha256=QOkc8QD0rEj0ftcJWJqVyO9qFAgVXrj1rl9R9jARSqc,1017
7
+ apis_acdhch_default_settings/views.py,sha256=4fwNnkjH-X4T2zojGTFndxvznOl_3JavHbmpDLD6wOA,1022
8
+ apis_acdhch_default_settings-2.0.0.dist-info/LICENSE,sha256=cMJgiPvvZVbZQcWrf-s1Es1W2b8sxKA0C7HlD4n8_Oo,1146
9
+ apis_acdhch_default_settings-2.0.0.dist-info/METADATA,sha256=kvUFBsRflpAyFcNzTR6Jj3i8cxbvPe2jDxPJezdImr4,1340
10
+ apis_acdhch_default_settings-2.0.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
11
+ apis_acdhch_default_settings-2.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,22 +0,0 @@
1
- import functools
2
- import requests
3
- import os
4
-
5
- from django.conf import settings
6
-
7
-
8
- @functools.cache
9
- def get_imprint() -> str:
10
- base_url = getattr(settings, "ACDH_IMPRINT_URL", "https://imprint.acdh.oeaw.ac.at/")
11
- redmine_id = getattr(settings, "REDMINE_ID", os.getenv("SERVICE_ID", ""))
12
-
13
- r = requests.get(f"{base_url}{redmine_id}")
14
-
15
- if r and redmine_id:
16
- return r.text
17
- else:
18
- return """
19
- One of our services is currently not available. Please try it later or write
20
- an email to acdh@oeaw.ac.at; if you are service provider, make sure that you
21
- provided ACDH_IMPRINT_URL and REDMINE_ID.
22
- """
@@ -1,11 +0,0 @@
1
- apis_acdhch_default_settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- apis_acdhch_default_settings/ldapauth.py,sha256=P1NDgWG2Pp4JzqoETq3VDC3DtECoEIXWBA3Lzn6CUIA,423
3
- apis_acdhch_default_settings/settings.py,sha256=9vmQBm7-mntCUwJUZQ1NWje1YPt4pQrlBARcXSO2jbQ,9161
4
- apis_acdhch_default_settings/templates/base.html,sha256=c3QhbTzJLzCii-Ck5x0wftHx_Y0aFhPfJUhUVknz_Ks,217
5
- apis_acdhch_default_settings/templates/imprint.html,sha256=juOqq6yzT9FMhjPjhbofDPZxRNO2fhOLlS478reFjE0,254
6
- apis_acdhch_default_settings/urls.py,sha256=Fr5zKACUYS31awqERkJNaa_SNKJJLEwlsPIbZsfqyTM,1090
7
- apis_acdhch_default_settings/utils.py,sha256=9uh0oQMPirTYvGxMg1f8IrOqrsxdxa8UgDJOrZaJdPs,647
8
- apis_acdhch_default_settings-1.7.0.dist-info/LICENSE,sha256=cMJgiPvvZVbZQcWrf-s1Es1W2b8sxKA0C7HlD4n8_Oo,1146
9
- apis_acdhch_default_settings-1.7.0.dist-info/METADATA,sha256=hrvVziiFYXVZN1tyyBV4ns8vLSmngFsVzNM81U5-JMg,1292
10
- apis_acdhch_default_settings-1.7.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
11
- apis_acdhch_default_settings-1.7.0.dist-info/RECORD,,