igs-slm 0.1.4b0__py3-none-any.whl → 0.1.5b0__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.
Files changed (149) hide show
  1. igs_slm-0.1.5b0.dist-info/METADATA +115 -0
  2. {igs_slm-0.1.4b0.dist-info → igs_slm-0.1.5b0.dist-info}/RECORD +192 -172
  3. {igs_slm-0.1.4b0.dist-info → igs_slm-0.1.5b0.dist-info}/WHEEL +1 -1
  4. igs_slm-0.1.5b0.dist-info/entry_points.txt +3 -0
  5. {igs_slm-0.1.4b0.dist-info → igs_slm-0.1.5b0.dist-info/licenses}/LICENSE +1 -1
  6. slm/__init__.py +17 -14
  7. slm/admin.py +32 -5
  8. slm/api/edit/views.py +22 -9
  9. slm/api/public/views.py +9 -7
  10. slm/api/views.py +45 -6
  11. slm/apps.py +28 -6
  12. slm/authentication.py +3 -2
  13. slm/bin/startproject.py +102 -31
  14. slm/bin/templates/{{ project_dir }}/pyproject.toml +30 -21
  15. slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/base.py +12 -1
  16. slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/__init__.py +5 -27
  17. slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/production/__init__.py +6 -27
  18. slm/bin/templates/{{ project_dir }}/src/sites/{{ site }}/validation.py +29 -0
  19. slm/context.py +5 -0
  20. slm/defines/AlertLevel.py +10 -2
  21. slm/defines/AntennaCalibration.py +6 -4
  22. slm/defines/AntennaFeatures.py +12 -9
  23. slm/defines/AntennaReferencePoint.py +12 -10
  24. slm/defines/Aspiration.py +4 -2
  25. slm/defines/CardinalDirection.py +6 -4
  26. slm/defines/CollocationStatus.py +3 -1
  27. slm/defines/EquipmentState.py +6 -12
  28. slm/defines/FlagSeverity.py +4 -2
  29. slm/defines/FractureSpacing.py +7 -5
  30. slm/defines/FrequencyStandardType.py +6 -4
  31. slm/defines/GeodesyMLVersion.py +2 -0
  32. slm/defines/Instrumentation.py +9 -7
  33. slm/defines/LogEntryType.py +17 -15
  34. slm/defines/SLMFileType.py +4 -2
  35. slm/defines/SiteFileUploadStatus.py +7 -24
  36. slm/defines/SiteLogFormat.py +8 -32
  37. slm/defines/SiteLogStatus.py +9 -28
  38. slm/defines/TectonicPlates.py +18 -16
  39. slm/manage.py +24 -0
  40. slm/management/commands/check_upgrade.py +142 -0
  41. slm/management/commands/generate_sinex.py +110 -92
  42. slm/management/commands/head_from_index.py +11 -8
  43. slm/management/commands/import_archive.py +27 -18
  44. slm/management/commands/import_equipment.py +1 -1
  45. slm/management/commands/sitelog.py +1 -3
  46. slm/management/commands/synchronize.py +1 -1
  47. slm/management/commands/validate_db.py +6 -4
  48. slm/map/defines.py +18 -14
  49. slm/map/templates/slm/map.html +4 -6
  50. slm/migrations/0001_remove_archiveindex_no_overlapping_ranges_per_site_and_more.py +26 -0
  51. slm/migrations/0002_alter_archivedsitelog_file_and_more.py +44 -0
  52. slm/migrations/0003_alter_archivedsitelog_name_and_more.py +35 -0
  53. slm/migrations/0004_alter_site_name.py +24 -0
  54. slm/migrations/0005_slmversion.py +30 -0
  55. slm/migrations/0017_alter_logentry_unique_together_and_more.py +3 -1
  56. slm/migrations/0018_afix_deleted.py +3 -1
  57. slm/migrations/0018_alter_siteantenna_options_and_more.py +87 -56
  58. slm/migrations/0019_remove_siteantenna_marker_enu_siteantenna_marker_une_and_more.py +1 -1
  59. slm/migrations/0023_archivedsitelog_gml_version_and_more.py +1 -1
  60. slm/migrations/0031_alter_antenna_features.py +44 -0
  61. slm/migrations/0032_archiveindex_valid_range_and_more.py +84 -0
  62. slm/migrations/add_index_order_index.py +54 -0
  63. slm/migrations/normalize_index.py +147 -0
  64. slm/migrations/simplify_index.py +48 -0
  65. slm/migrations/verify_index.py +67 -0
  66. slm/models/__init__.py +2 -0
  67. slm/models/alerts.py +7 -10
  68. slm/models/data.py +1 -2
  69. slm/models/equipment.py +1 -1
  70. slm/models/fields.py +41 -0
  71. slm/models/index.py +183 -53
  72. slm/models/sitelog.py +35 -38
  73. slm/models/system.py +72 -31
  74. slm/models/user.py +1 -1
  75. slm/parsing/__init__.py +33 -16
  76. slm/parsing/legacy/binding.py +65 -34
  77. slm/parsing/legacy/parser.py +2 -2
  78. slm/parsing/xsd/binding.py +1 -1
  79. slm/parsing/xsd/parser.py +1 -2
  80. slm/receivers/__init__.py +2 -2
  81. slm/receivers/index.py +2 -1
  82. slm/receivers/migration.py +21 -0
  83. slm/settings/__init__.py +192 -4
  84. slm/settings/assets.py +26 -0
  85. slm/settings/auth.py +18 -14
  86. slm/settings/ckeditor.py +12 -6
  87. slm/settings/debug.py +2 -2
  88. slm/settings/emails.py +50 -0
  89. slm/settings/internationalization.py +8 -6
  90. slm/settings/logging.py +100 -88
  91. slm/settings/platform/darwin.py +16 -6
  92. slm/settings/rest.py +20 -15
  93. slm/settings/root.py +192 -98
  94. slm/settings/routines.py +5 -1
  95. slm/settings/secrets.py +20 -31
  96. slm/settings/security.py +7 -5
  97. slm/settings/slm.py +35 -16
  98. slm/settings/static_templates.py +12 -9
  99. slm/settings/templates.py +31 -25
  100. slm/settings/uploads.py +33 -5
  101. slm/settings/urls.py +1 -1
  102. slm/settings/validation.py +165 -165
  103. slm/signals.py +3 -2
  104. slm/static/slm/css/style.css +37 -36
  105. slm/static/slm/js/autocomplete.js +6 -4
  106. slm/static/slm/js/file_modal.js +62 -0
  107. slm/static/slm/js/form.js +3 -3
  108. slm/static/slm/js/formWidget.js +3 -3
  109. slm/static/slm/js/persistable.js +5 -1
  110. slm/templates/admin/base.html +1 -0
  111. slm/templates/rest_framework/base.html +23 -11
  112. slm/templates/slm/base.html +27 -22
  113. slm/templates/slm/forms/widgets/auto_complete.html +12 -11
  114. slm/templates/slm/forms/widgets/auto_complete_multiple.html +8 -7
  115. slm/templates/slm/station/download.html +6 -6
  116. slm/templates/slm/station/edit.html +9 -17
  117. slm/templates/slm/station/review.html +5 -3
  118. slm/templates/slm/station/upload.html +4 -1
  119. slm/templates/slm/station/uploads/legacy.html +1 -1
  120. slm/templates/slm/widgets/alert_scroll.html +4 -8
  121. slm/templates/slm/widgets/filelist.html +0 -5
  122. slm/templates/slm/widgets/log_scroll.html +2 -13
  123. slm/templates/slm/widgets/stationlist.html +2 -8
  124. slm/templatetags/slm.py +70 -9
  125. slm/utils.py +13 -4
  126. slm/validators.py +14 -14
  127. slm/views.py +6 -6
  128. slm/wsgi.py +16 -0
  129. igs_slm-0.1.4b0.dist-info/METADATA +0 -154
  130. igs_slm-0.1.4b0.dist-info/entry_points.txt +0 -3
  131. slm/bin/templates/{{ project_dir }}/sites/{{ site }}/validation.py +0 -11
  132. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/__init__.py +0 -0
  133. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/__init__.py +0 -0
  134. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/local.py +0 -0
  135. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/wsgi.py +0 -0
  136. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/manage.py +0 -0
  137. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/production/wsgi.py +0 -0
  138. /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/urls.py +0 -0
  139. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/__init__.py +0 -0
  140. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/admin.py +0 -0
  141. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/apps.py +0 -0
  142. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/__init__.py +0 -0
  143. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/commands/__init__.py +0 -0
  144. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/commands/import_archive.py +0 -0
  145. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/migrations/__init__.py +0 -0
  146. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/models.py +0 -0
  147. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/templates/slm/base.html +0 -0
  148. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/urls.py +0 -0
  149. /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/views.py +0 -0
slm/settings/rest.py CHANGED
@@ -4,18 +4,23 @@ Django rest framework configuration parameters
4
4
  https://www.django-rest-framework.org/
5
5
  """
6
6
 
7
- REST_FRAMEWORK = {
8
- "DEFAULT_AUTHENTICATION_CLASSES": [
9
- "rest_framework.authentication.SessionAuthentication",
10
- #'slm.authentication.SignatureAuthentication', TODO library authentication
11
- ],
12
- "DEFAULT_PERMISSION_CLASSES": [
13
- "rest_framework.permissions.IsAuthenticatedOrReadOnly"
14
- ],
15
- "DEFAULT_RENDERER_CLASSES": [
16
- "rest_framework.renderers.JSONRenderer",
17
- "rest_framework.renderers.BrowsableAPIRenderer",
18
- #'drf_renderer_xlsx.renderers.XLSXRenderer',
19
- #'rest_framework_csv.renderers.CSVRenderer'
20
- ],
21
- }
7
+ from slm.settings import set_default
8
+
9
+ set_default(
10
+ "REST_FRAMEWORK",
11
+ {
12
+ "DEFAULT_AUTHENTICATION_CLASSES": [
13
+ "rest_framework.authentication.SessionAuthentication",
14
+ #'slm.authentication.SignatureAuthentication', TODO library authentication
15
+ ],
16
+ "DEFAULT_PERMISSION_CLASSES": [
17
+ "rest_framework.permissions.IsAuthenticatedOrReadOnly"
18
+ ],
19
+ "DEFAULT_RENDERER_CLASSES": [
20
+ "rest_framework.renderers.JSONRenderer",
21
+ "rest_framework.renderers.BrowsableAPIRenderer",
22
+ #'drf_renderer_xlsx.renderers.XLSXRenderer',
23
+ #'rest_framework_csv.renderers.CSVRenderer'
24
+ ],
25
+ },
26
+ )
slm/settings/root.py CHANGED
@@ -8,145 +8,239 @@ For the full list of settings and their values, see
8
8
  https://docs.djangoproject.com/en/stable/ref/settings/
9
9
  """
10
10
 
11
+ import os
11
12
  import platform
12
13
  from pathlib import Path
13
14
 
14
15
  from django.contrib.messages import constants as message_constants
16
+ from django.core.exceptions import ImproperlyConfigured
15
17
  from split_settings.tools import include, optional
16
18
 
17
- from slm.settings import get_setting, set_default
19
+ from slm.settings import env as settings_environment
20
+ from slm.settings import (
21
+ get_setting,
22
+ set_default,
23
+ slm_path_mk_dirs_must_exist,
24
+ slm_path_must_exist,
25
+ )
26
+
27
+ env = settings_environment()
18
28
 
19
- DEBUG = get_setting("DEBUG", False)
29
+ DEBUG = env("DEBUG", default=get_setting("DEBUG", False))
30
+
31
+ # manage.py will set this to true if django has been loaded to run a
32
+ # management command - this mostly influences logging
33
+ SLM_MANAGEMENT_MODE = env.parse_value(
34
+ os.environ.get("SLM_MANAGEMENT_FLAG", False), bool
35
+ )
20
36
 
21
37
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
22
- BASE_DIR = get_setting("BASE_DIR", Path(__file__).resolve().parent.parent)
23
- SITE_DIR = get_setting("SITE_DIR", BASE_DIR)
24
- DJANGO_DEBUG_TOOLBAR = get_setting("DJANGO_DEBUG_TOOLBAR", False)
38
+ BASE_DIR = Path(
39
+ env(
40
+ "BASE_DIR",
41
+ str,
42
+ default=get_setting("BASE_DIR", env.NOTSET),
43
+ )
44
+ ).resolve()
45
+
46
+ if not BASE_DIR.is_dir():
47
+ raise ImproperlyConfigured(f"BASE_DIR: {BASE_DIR} is not a directory.")
48
+
49
+ SLM_DEBUG_TOOLBAR = env(
50
+ "SLM_DEBUG_TOOLBAR", bool, default=get_setting("DJANGO_DEBUG_TOOLBAR", DEBUG)
51
+ )
52
+ SLM_SECURITY_DEFAULTS = env(
53
+ "SLM_SECURITY_DEFAULTS",
54
+ bool,
55
+ default=get_setting("SLM_SECURITY_DEFAULTS", not DEBUG),
56
+ )
57
+
58
+ SLM_IGS_VALIDATION = env(
59
+ "SLM_IGS_VALIDATION", bool, default=get_setting("SLM_IGS_VALIDATION", True)
60
+ )
61
+
62
+ SLM_ADMIN_MAP = env("SLM_ADMIN_MAP", bool, default=get_setting("SLM_ADMIN_MAP", True))
63
+ SLM_SITE_NAME = env("SLM_SITE_NAME", str, default=get_setting("SLM_SITE_NAME", ""))
64
+ SLM_ORG_NAME = env("SLM_ORG_NAME", str, default=get_setting("SLM_ORG_NAME", "SLM"))
25
65
 
26
66
  # Quick-start development settings - unsuitable for production
27
- # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
28
-
29
- ALLOWED_HOSTS = get_setting("ALLOWED_HOSTS", [])
30
- if ALLOWED_HOSTS:
31
- set_default("SERVER_EMAIL", f"noreply@{ALLOWED_HOSTS[0]}")
32
-
33
- # Application definition
34
-
35
- # django.contrib.___ gives us useful tools for authentication, etc.
36
- INSTALLED_APPS = [
37
- # "slm.map",
38
- "slm",
39
- "crispy_forms",
40
- "crispy_bootstrap5",
41
- "ckeditor_uploader",
42
- "ckeditor",
43
- "polymorphic",
44
- "rest_framework",
45
- "rest_framework_gis",
46
- "render_static",
47
- "django_routines",
48
- "django_typer",
49
- "django_filters",
50
- "compressor",
51
- "widget_tweaks",
52
- #'django.contrib.postgres',
53
- "django.contrib.admin",
54
- "django.contrib.auth",
55
- "django.contrib.contenttypes",
56
- "django.contrib.sessions",
57
- "django.contrib.messages",
58
- "django.contrib.staticfiles",
59
- "django.contrib.sites",
60
- "django.contrib.gis",
61
- "allauth",
62
- "allauth.account",
63
- ]
64
-
65
- CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
66
- CRISPY_TEMPLATE_PACK = "bootstrap5"
67
-
68
- STATICFILES_FINDERS = (
69
- "django.contrib.staticfiles.finders.FileSystemFinder",
70
- "django.contrib.staticfiles.finders.AppDirectoriesFinder",
71
- "compressor.finders.CompressorFinder",
67
+ # See https://docs.djangoproject.com/en/stable/howto/deployment/checklist/
68
+
69
+ ALLOWED_HOSTS = env.list(
70
+ "ALLOWED_HOSTS",
71
+ default=get_setting(
72
+ "ALLOWED_HOSTS",
73
+ ["localhost", "127.0.0.1", "[::1]"]
74
+ if DEBUG
75
+ else ([SLM_SITE_NAME] if SLM_SITE_NAME else []),
76
+ ),
77
+ )
78
+ if not SLM_SITE_NAME and ALLOWED_HOSTS:
79
+ SLM_SITE_NAME = ALLOWED_HOSTS[0]
80
+
81
+ INSTALLED_APPS = set_default(
82
+ "INSTALLED_APPS",
83
+ [
84
+ "slm",
85
+ "crispy_forms",
86
+ "crispy_bootstrap5",
87
+ "ckeditor_uploader",
88
+ "ckeditor",
89
+ "polymorphic",
90
+ "rest_framework",
91
+ "rest_framework_gis",
92
+ "render_static",
93
+ "django_routines",
94
+ "django_typer",
95
+ "django_filters",
96
+ "compressor",
97
+ "widget_tweaks",
98
+ "django.contrib.postgres",
99
+ "django.contrib.admin",
100
+ "django.contrib.auth",
101
+ "django.contrib.contenttypes",
102
+ "django.contrib.sessions",
103
+ "django.contrib.messages",
104
+ "django.contrib.staticfiles",
105
+ "django.contrib.sites",
106
+ "django.contrib.gis",
107
+ "allauth",
108
+ "allauth.account",
109
+ ],
110
+ )
111
+
112
+ if SLM_ADMIN_MAP:
113
+ INSTALLED_APPS.insert(0, "slm.map")
114
+
115
+
116
+ SLM_DATABASE = env(
117
+ "SLM_DATABASE", str, default=set_default("SLM_DATABASE", "postgis:///slm")
118
+ )
119
+ DATABASES = set_default("DATABASES", {})
120
+ DATABASES["default"] = {
121
+ "ATOMIC_REQUESTS": True,
122
+ **DATABASES.get("default", {}),
123
+ **env.db_url_config(
124
+ SLM_DATABASE,
125
+ engine="django.contrib.gis.db.backends.postgis", # must have postgis!
126
+ ),
127
+ }
128
+
129
+ SLM_CACHE = env("SLM_CACHE", str, default=set_default("SLM_CACHE", "locmemcache://"))
130
+ CACHES = set_default("CACHES", {})
131
+ CACHES["default"] = {**CACHES.get("default", {}), **env.cache_url_config(SLM_CACHE)}
132
+
133
+ set_default("CRISPY_ALLOWED_TEMPLATE_PACKS", "bootstrap5")
134
+ set_default("CRISPY_TEMPLATE_PACK", "bootstrap5")
135
+
136
+ set_default(
137
+ "STATICFILES_FINDERS",
138
+ (
139
+ "django.contrib.staticfiles.finders.FileSystemFinder",
140
+ "django.contrib.staticfiles.finders.AppDirectoriesFinder",
141
+ "compressor.finders.CompressorFinder",
142
+ ),
72
143
  )
73
144
 
74
145
  # this statement was added during creation of custom user model
75
- AUTH_USER_MODEL = "slm.User"
76
-
77
- MIDDLEWARE = [
78
- "django.middleware.security.SecurityMiddleware",
79
- "django.contrib.sessions.middleware.SessionMiddleware",
80
- "django.middleware.common.CommonMiddleware",
81
- "django.middleware.csrf.CsrfViewMiddleware",
82
- "django.contrib.auth.middleware.AuthenticationMiddleware",
83
- "allauth.account.middleware.AccountMiddleware",
84
- "slm.middleware.SetLastVisitMiddleware",
85
- "django.contrib.messages.middleware.MessageMiddleware",
86
- "django.middleware.clickjacking.XFrameOptionsMiddleware",
87
- ]
88
-
89
- ROOT_URLCONF = "slm.settings.urls"
146
+ set_default("AUTH_USER_MODEL", "slm.User")
147
+
148
+ set_default(
149
+ "MIDDLEWARE",
150
+ [
151
+ "django.middleware.security.SecurityMiddleware",
152
+ "django.contrib.sessions.middleware.SessionMiddleware",
153
+ "django.middleware.common.CommonMiddleware",
154
+ "django.middleware.csrf.CsrfViewMiddleware",
155
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
156
+ "allauth.account.middleware.AccountMiddleware",
157
+ "slm.middleware.SetLastVisitMiddleware",
158
+ "django.contrib.messages.middleware.MessageMiddleware",
159
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
160
+ ],
161
+ )
90
162
 
91
- # Password validation
92
- # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
93
-
94
- AUTH_PASSWORD_VALIDATORS = [
95
- {
96
- "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
97
- },
98
- {
99
- "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
100
- },
101
- {
102
- "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
103
- },
104
- {
105
- "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
106
- },
107
- ]
163
+ set_default("ROOT_URLCONF", "slm.settings.urls")
108
164
 
165
+ # Password validation
166
+ # https://docs.djangoproject.com/en/stable/ref/settings/#auth-password-validators
167
+
168
+ set_default(
169
+ "AUTH_PASSWORD_VALIDATORS",
170
+ [
171
+ {
172
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
173
+ },
174
+ {
175
+ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
176
+ },
177
+ {
178
+ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
179
+ },
180
+ {
181
+ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
182
+ },
183
+ ],
184
+ )
109
185
 
110
186
  # Static files (CSS, JavaScript, Images)
111
- # https://docs.djangoproject.com/en/3.2/howto/static-files/
187
+ # https://docs.djangoproject.com/en/stable/howto/static-files/
112
188
 
113
189
  # Following two statements added to assist with handling of static files
114
- STATIC_URL = "/static/"
190
+ set_default("STATIC_URL", "/static/")
115
191
 
116
192
  # Default primary key field type
117
- # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
193
+ # https://docs.djangoproject.com/en/stable/ref/settings/#default-auto-field
118
194
 
119
- DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
195
+ set_default("DEFAULT_AUTO_FIELD", "django.db.models.BigAutoField")
120
196
 
121
197
  set_default("SITE_ID", 1)
122
198
 
123
- STATIC_ROOT = get_setting("STATIC_ROOT", SITE_DIR / "static")
199
+ STATIC_ROOT = env(
200
+ "STATIC_ROOT",
201
+ slm_path_mk_dirs_must_exist,
202
+ default=get_setting("STATIC_ROOT", BASE_DIR / "static"),
203
+ )
124
204
 
125
- COMPRESS_OFFLINE = True
126
- COMPRESS_ROOT = STATIC_ROOT
127
- COMPRESS_URL = STATIC_URL
205
+ env = settings_environment()
128
206
 
207
+ GDAL_LIBRARY_PATH = env(
208
+ "GDAL_LIBRARY_PATH",
209
+ slm_path_must_exist,
210
+ default=get_setting("GDAL_LIBRARY_PATH", None),
211
+ )
212
+ GEOS_LIBRARY_PATH = env(
213
+ "GEOS_LIBRARY_PATH",
214
+ slm_path_must_exist,
215
+ default=get_setting("GEOS_LIBRARY_PATH", None),
216
+ )
129
217
 
130
- include("internationalization.py")
131
218
  include("slm.py")
219
+ include("emails.py")
220
+ include("internationalization.py")
132
221
  include("secrets.py")
133
222
  include("logging.py")
134
223
  include("templates.py")
135
224
  include("static_templates.py")
136
- include("routines.py")
137
225
  include("auth.py")
138
226
  include("rest.py")
139
227
  include("debug.py")
140
228
  include("uploads.py")
141
229
  include("ckeditor.py")
142
- include("security.py")
143
- include("validation.py")
230
+ if SLM_SECURITY_DEFAULTS:
231
+ include("security.py")
232
+ if SLM_IGS_VALIDATION:
233
+ include("validation.py")
234
+ include("assets.py")
235
+ include("routines.py")
144
236
 
145
237
  # will either be darwin, windows or linux
146
238
  include(optional(f"./platform/{platform.system().lower()}.py"))
147
239
 
240
+ set_default(
241
+ "MESSAGE_LEVEL", message_constants.DEBUG if DEBUG else message_constants.INFO
242
+ )
148
243
 
149
- # Path(STATIC_ROOT).mkdir(parents=True, exist_ok=True)
150
- # Path(MEDIA_ROOT).mkdir(parents=True, exist_ok=True)
151
-
152
- MESSAGE_LEVEL = message_constants.DEBUG if DEBUG else message_constants.INFO
244
+ WSGI_APPLICATION = env(
245
+ "WSGI_APPLICATION", default=get_setting("WSGI_APPLICATION", "slm.wsgi")
246
+ )
slm/settings/routines.py CHANGED
@@ -1,6 +1,8 @@
1
1
  from django.utils.translation import gettext_lazy as _
2
2
  from django_routines import command, routine
3
3
 
4
+ from slm.settings import get_setting
5
+
4
6
  routine(
5
7
  "deploy",
6
8
  _(
@@ -29,7 +31,9 @@ command("deploy", "shellcompletion", "install", switches=["initial"])
29
31
  command("deploy", "migrate", priority=11)
30
32
  command("deploy", "renderstatic", priority=20)
31
33
  command("deploy", "collectstatic", "--no-input", priority=21)
32
- command("deploy", "set_site", priority=22)
34
+ if get_setting("COMPRESS_OFFLINE", False) and get_setting("COMPRESS_ENABLED", False):
35
+ command("deploy", "compress", priority=22)
36
+ command("deploy", "set_site", priority=23)
33
37
  command("deploy", "validate_db", "--schema", priority=30, switches=["re-validate"])
34
38
  command("deploy", "synchronize", priority=32, switches=["re-validate"])
35
39
 
slm/settings/secrets.py CHANGED
@@ -1,37 +1,26 @@
1
1
  import os
2
2
  from pathlib import Path
3
3
 
4
- from slm.settings import get_setting
4
+ from slm.settings import env as settings_environment
5
+ from slm.settings import get_setting, slm_path_mk_dirs_must_exist
5
6
 
6
- SLM_SECRETS_DIR = get_setting(
7
- "SLM_SECRETS_DIR", Path(get_setting("SITE_DIR")) / "secrets"
8
- )
9
-
10
-
11
- def generate_secret_key(filename):
12
- from django.core.management.utils import get_random_secret_key
13
-
14
- with open(filename, "w") as f:
15
- f.write("%s\n" % get_random_secret_key())
16
- os.chmod(filename, 0o640)
17
-
18
-
19
- def get_secret_key(filename):
20
- with open(filename, "r") as f:
21
- return f.readlines()[0]
7
+ env = settings_environment()
22
8
 
9
+ SLM_SECRETS_DIR = env(
10
+ "SLM_SECRETS_DIR",
11
+ slm_path_mk_dirs_must_exist,
12
+ default=get_setting("SLM_SECRETS_DIR", Path(get_setting("BASE_DIR")) / "secrets"),
13
+ )
23
14
 
24
- if not os.path.exists(SLM_SECRETS_DIR):
25
- os.makedirs(SLM_SECRETS_DIR)
26
-
27
-
28
- sk_file = os.path.join(SLM_SECRETS_DIR, "secret_key")
29
-
30
- if not os.path.exists(sk_file):
31
- generate_secret_key(sk_file)
32
-
33
- SECRET_KEY = get_secret_key(sk_file)
34
-
35
- if len(SECRET_KEY) == 0:
36
- generate_secret_key(sk_file)
37
- SECRET_KEY = get_secret_key(sk_file)
15
+ SECRET_KEY = env("SECRET_KEY", default=get_setting("SECRET_KEY", None))
16
+ if not SECRET_KEY:
17
+ sk_file = Path(SLM_SECRETS_DIR) / "secret_key"
18
+ if not sk_file.is_file():
19
+ from django.core.management.utils import get_random_secret_key
20
+
21
+ os.makedirs(SLM_SECRETS_DIR, exist_ok=True)
22
+ SECRET_KEY = get_random_secret_key()
23
+ sk_file.write_text(f"{SECRET_KEY}\n")
24
+ sk_file.chmod(0o640)
25
+ else:
26
+ SECRET_KEY = sk_file.read_text().strip()
slm/settings/security.py CHANGED
@@ -1,5 +1,7 @@
1
- SECURE_SSL_REDIRECT = True
2
- CSRF_COOKIE_SECURE = True
3
- SESSION_COOKIE_SECURE = True
4
- SECURE_REFERRER_POLICY = "origin"
5
- X_FRAME_OPTIONS = "DENY"
1
+ from slm.settings import set_default
2
+
3
+ set_default("SECURE_SSL_REDIRECT", True)
4
+ set_default("CSRF_COOKIE_SECURE", True)
5
+ set_default("SESSION_COOKIE_SECURE", True)
6
+ set_default("SECURE_REFERRER_POLICY", "origin")
7
+ set_default("X_FRAME_OPTIONS", "DENY")
slm/settings/slm.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
- SLM Specific Configuration parameters go here.
2
+ SLM Specific Configuration parameters go here. what
3
3
  """
4
4
 
5
- import os
5
+ from django.utils.translation import gettext_lazy as _
6
6
 
7
7
  from slm.defines import (
8
8
  AlertLevel,
@@ -10,11 +10,12 @@ from slm.defines import (
10
10
  SiteFileUploadStatus,
11
11
  SiteLogStatus,
12
12
  )
13
+ from slm.settings import env as settings_environment
13
14
  from slm.settings import get_setting, set_default
14
15
 
15
- # manage.py will set this to true if django has been loaded to run a
16
- # management command
17
- SLM_MANAGEMENT_MODE = os.environ.get("SLM_MANAGEMENT_FLAG", False) == "ON"
16
+ env = settings_environment()
17
+
18
+ DEBUG = get_setting("DEBUG")
18
19
 
19
20
  set_default(
20
21
  "SLM_ALERT_COLORS",
@@ -50,10 +51,14 @@ set_default(
50
51
 
51
52
  # if True, for subsections and missing sections, placeholder structures will
52
53
  # be added to the logs
53
- set_default("SLM_LEGACY_PLACEHOLDERS", True)
54
+ SLM_LEGACY_PLACEHOLDERS = env(
55
+ "SLM_LEGACY_PLACEHOLDERS", default=get_setting("SLM_LEGACY_PLACEHOLDERS", True)
56
+ )
54
57
 
55
58
  # the maximum file upload size in Mega Bytes
56
- set_default("SLM_MAX_UPLOAD_SIZE_MB", 100)
59
+ SLM_MAX_UPLOAD_SIZE_MB = env(
60
+ "SLM_MAX_UPLOAD_SIZE_MB", default=get_setting("SLM_MAX_UPLOAD_SIZE_MB", 100)
61
+ )
57
62
 
58
63
  # a map of file icons (css) from mimetype subtypes
59
64
  set_default(
@@ -79,17 +84,13 @@ set_default(
79
84
 
80
85
  # generated image thumbnail size in pixels - this is a tuple of maximum width
81
86
  # and height - the aspect ratio will be preserved
82
- set_default("SLM_THUMBNAIL_SIZE", 250)
83
-
84
- # during deploy the current Site will be set to SLM_SITE_NAME, SLM_ORG_NAME
85
- # The name of the organization used in communications
86
- set_default("SLM_ORG_NAME", "SLM")
87
-
88
- set_default("SLM_SITE_NAME", (get_setting("ALLOWED_HOSTS", []) or ["localhost"])[0])
87
+ SLM_THUMBNAIL_SIZE = env(
88
+ "SLM_THUMBNAIL_SIZE", int, default=get_setting("SLM_THUMBNAIL_SIZE", 250)
89
+ )
89
90
 
90
91
  # set this to either http or https, this will be used to determine the protocol
91
92
  # of absolute uri links where a request object is not present
92
- set_default("SLM_HTTP_PROTOCOL", None)
93
+ set_default("SLM_HTTP_PROTOCOL", "http" if DEBUG else "https")
93
94
 
94
95
  # this should point to a cached property that holds the set of Django
95
96
  # permissions relevant to the SLM - if you extend the permission set override
@@ -107,7 +108,12 @@ set_default(
107
108
  # will prolong the request. It can be useful to disable this during testing to
108
109
  # reduce load times. It is recommended to leave this set to the default setting
109
110
  # in production
110
- set_default("SLM_PRELOAD_SCHEMAS", [geo for geo in GeodesyMLVersion])
111
+ set_default(
112
+ "SLM_PRELOAD_SCHEMAS",
113
+ []
114
+ if DEBUG or get_setting("SLM_MANAGEMENT_MODE", False)
115
+ else [geo for geo in GeodesyMLVersion],
116
+ )
111
117
 
112
118
  # By default the SLM will not send moderation related emails to user accounts
113
119
  # who have never logged in, set this to False to disable this behavior
@@ -186,3 +192,16 @@ SLM_URL_MOUNTS = []
186
192
  # do not need to set this field unless you are serving files off a different
187
193
  # instance than the instance that generates serialized artifacts
188
194
  SLM_FILE_DOMAIN = None
195
+
196
+
197
+ set_default("SLM_STATION_NAME_REGEX", None)
198
+ set_default("SLM_STATION_NAME_HELP", _("The name of the station."))
199
+
200
+ # IGS Settings:
201
+ # SLM_STATION_NAME_REGEX = r"[\w]{4}[\d]{2}[\w]{3}"
202
+ # SLM_STATION_NAME_HELP = _(
203
+ # "This is the 9 Character station name (XXXXMRCCC) used in RINEX 3 "
204
+ # "filenames Format: (XXXX - existing four character IGS station "
205
+ # "name, M - Monument or marker number (0-9), R - Receiver number "
206
+ # "(0-9), CCC - Three digit ISO 3166-1 country code)"
207
+ # )
@@ -1,4 +1,4 @@
1
- from slm.settings import get_setting
1
+ from slm.settings import get_setting, set_default
2
2
 
3
3
 
4
4
  def get_enum_context():
@@ -43,11 +43,14 @@ def get_icon_context():
43
43
  }
44
44
 
45
45
 
46
- STATIC_TEMPLATES = {
47
- "templates": [
48
- ("slm/js/urls.js", {"dest": get_setting("STATIC_ROOT") / "urls.js"}),
49
- ("slm/js/enums.js", {"context": get_enum_context}),
50
- ("slm/js/fileIcons.js", {"context": get_icon_context}),
51
- ("slm/css/defines.css", {"context": get_defines_context}),
52
- ]
53
- }
46
+ set_default(
47
+ "STATIC_TEMPLATES",
48
+ {
49
+ "templates": [
50
+ ("slm/js/urls.js", {"dest": get_setting("STATIC_ROOT") / "urls.js"}),
51
+ ("slm/js/enums.js", {"context": get_enum_context}),
52
+ ("slm/js/fileIcons.js", {"context": get_icon_context}),
53
+ ("slm/css/defines.css", {"context": get_defines_context}),
54
+ ]
55
+ },
56
+ )
slm/settings/templates.py CHANGED
@@ -1,29 +1,35 @@
1
1
  from jinja2 import select_autoescape
2
2
 
3
- TEMPLATES = [
4
- {
5
- "BACKEND": "django.template.backends.django.DjangoTemplates",
6
- "APP_DIRS": True,
7
- "OPTIONS": {
8
- "context_processors": [
9
- "django.template.context_processors.debug",
10
- "django.template.context_processors.request",
11
- "django.contrib.auth.context_processors.auth",
12
- "django.contrib.messages.context_processors.messages",
13
- ],
14
- "builtins": ["slm.templatetags.slm"],
3
+ from slm.settings import set_default
4
+
5
+ set_default(
6
+ "TEMPLATES",
7
+ [
8
+ {
9
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
10
+ "APP_DIRS": True,
11
+ "OPTIONS": {
12
+ "context_processors": [
13
+ "slm.context.globals",
14
+ "django.template.context_processors.debug",
15
+ "django.template.context_processors.request",
16
+ "django.contrib.auth.context_processors.auth",
17
+ "django.contrib.messages.context_processors.messages",
18
+ ],
19
+ "builtins": ["slm.templatetags.slm"],
20
+ },
15
21
  },
16
- },
17
- {
18
- "BACKEND": "django.template.backends.jinja2.Jinja2",
19
- "APP_DIRS": True,
20
- "OPTIONS": {
21
- "autoescape": select_autoescape(
22
- disabled_extensions=("log",),
23
- default_for_string=True,
24
- default=True,
25
- ),
26
- "environment": "slm.templatetags.jinja2.compat",
22
+ {
23
+ "BACKEND": "django.template.backends.jinja2.Jinja2",
24
+ "APP_DIRS": True,
25
+ "OPTIONS": {
26
+ "autoescape": select_autoescape(
27
+ disabled_extensions=("log",),
28
+ default_for_string=True,
29
+ default=True,
30
+ ),
31
+ "environment": "slm.templatetags.jinja2.compat",
32
+ },
27
33
  },
28
- },
29
- ]
34
+ ],
35
+ )