igs-slm 0.1.2b0__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.
- igs_slm-0.1.5b0.dist-info/METADATA +115 -0
- {igs_slm-0.1.2b0.dist-info → igs_slm-0.1.5b0.dist-info}/RECORD +192 -172
- {igs_slm-0.1.2b0.dist-info → igs_slm-0.1.5b0.dist-info}/WHEEL +1 -1
- igs_slm-0.1.5b0.dist-info/entry_points.txt +3 -0
- {igs_slm-0.1.2b0.dist-info → igs_slm-0.1.5b0.dist-info/licenses}/LICENSE +1 -1
- slm/__init__.py +17 -14
- slm/admin.py +32 -5
- slm/api/edit/views.py +22 -9
- slm/api/public/views.py +10 -8
- slm/api/views.py +45 -6
- slm/apps.py +28 -6
- slm/authentication.py +3 -2
- slm/bin/startproject.py +102 -31
- slm/bin/templates/{{ project_dir }}/pyproject.toml +30 -21
- slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/base.py +12 -1
- slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/__init__.py +5 -27
- slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/production/__init__.py +6 -27
- slm/bin/templates/{{ project_dir }}/src/sites/{{ site }}/validation.py +29 -0
- slm/context.py +5 -0
- slm/defines/AlertLevel.py +10 -2
- slm/defines/AntennaCalibration.py +6 -4
- slm/defines/AntennaFeatures.py +12 -9
- slm/defines/AntennaReferencePoint.py +12 -10
- slm/defines/Aspiration.py +4 -2
- slm/defines/CardinalDirection.py +6 -4
- slm/defines/CollocationStatus.py +3 -1
- slm/defines/EquipmentState.py +6 -12
- slm/defines/FlagSeverity.py +4 -2
- slm/defines/FractureSpacing.py +7 -5
- slm/defines/FrequencyStandardType.py +6 -4
- slm/defines/GeodesyMLVersion.py +2 -0
- slm/defines/Instrumentation.py +9 -7
- slm/defines/LogEntryType.py +17 -15
- slm/defines/SLMFileType.py +4 -2
- slm/defines/SiteFileUploadStatus.py +7 -24
- slm/defines/SiteLogFormat.py +8 -32
- slm/defines/SiteLogStatus.py +9 -28
- slm/defines/TectonicPlates.py +18 -16
- slm/manage.py +24 -0
- slm/management/commands/check_upgrade.py +142 -0
- slm/management/commands/generate_sinex.py +110 -92
- slm/management/commands/head_from_index.py +11 -8
- slm/management/commands/import_archive.py +27 -18
- slm/management/commands/import_equipment.py +1 -1
- slm/management/commands/sitelog.py +1 -3
- slm/management/commands/synchronize.py +1 -1
- slm/management/commands/validate_db.py +6 -4
- slm/map/defines.py +18 -14
- slm/map/templates/slm/map.html +4 -6
- slm/migrations/0001_remove_archiveindex_no_overlapping_ranges_per_site_and_more.py +26 -0
- slm/migrations/0002_alter_archivedsitelog_file_and_more.py +44 -0
- slm/migrations/0003_alter_archivedsitelog_name_and_more.py +35 -0
- slm/migrations/0004_alter_site_name.py +24 -0
- slm/migrations/0005_slmversion.py +30 -0
- slm/migrations/0017_alter_logentry_unique_together_and_more.py +3 -1
- slm/migrations/0018_afix_deleted.py +3 -1
- slm/migrations/0018_alter_siteantenna_options_and_more.py +87 -56
- slm/migrations/0019_remove_siteantenna_marker_enu_siteantenna_marker_une_and_more.py +1 -1
- slm/migrations/0023_archivedsitelog_gml_version_and_more.py +1 -1
- slm/migrations/0031_alter_antenna_features.py +44 -0
- slm/migrations/0032_archiveindex_valid_range_and_more.py +84 -0
- slm/migrations/add_index_order_index.py +54 -0
- slm/migrations/normalize_index.py +147 -0
- slm/migrations/simplify_index.py +48 -0
- slm/migrations/verify_index.py +67 -0
- slm/models/__init__.py +2 -0
- slm/models/alerts.py +7 -10
- slm/models/data.py +1 -2
- slm/models/equipment.py +1 -1
- slm/models/fields.py +41 -0
- slm/models/index.py +183 -53
- slm/models/sitelog.py +35 -38
- slm/models/system.py +72 -31
- slm/models/user.py +1 -1
- slm/parsing/__init__.py +34 -17
- slm/parsing/legacy/binding.py +65 -34
- slm/parsing/legacy/parser.py +2 -2
- slm/parsing/xsd/binding.py +1 -1
- slm/parsing/xsd/parser.py +1 -2
- slm/receivers/__init__.py +2 -2
- slm/receivers/index.py +2 -1
- slm/receivers/migration.py +21 -0
- slm/settings/__init__.py +192 -4
- slm/settings/assets.py +26 -0
- slm/settings/auth.py +18 -14
- slm/settings/ckeditor.py +12 -6
- slm/settings/debug.py +2 -2
- slm/settings/emails.py +50 -0
- slm/settings/internationalization.py +8 -6
- slm/settings/logging.py +100 -88
- slm/settings/platform/darwin.py +16 -6
- slm/settings/rest.py +20 -15
- slm/settings/root.py +192 -98
- slm/settings/routines.py +5 -1
- slm/settings/secrets.py +20 -31
- slm/settings/security.py +7 -5
- slm/settings/slm.py +35 -16
- slm/settings/static_templates.py +12 -9
- slm/settings/templates.py +31 -25
- slm/settings/uploads.py +33 -5
- slm/settings/urls.py +1 -1
- slm/settings/validation.py +165 -165
- slm/signals.py +3 -2
- slm/static/slm/css/style.css +37 -36
- slm/static/slm/js/autocomplete.js +6 -4
- slm/static/slm/js/file_modal.js +62 -0
- slm/static/slm/js/form.js +3 -3
- slm/static/slm/js/formWidget.js +3 -3
- slm/static/slm/js/persistable.js +5 -1
- slm/templates/admin/base.html +1 -0
- slm/templates/rest_framework/base.html +23 -11
- slm/templates/slm/base.html +27 -22
- slm/templates/slm/forms/widgets/auto_complete.html +12 -11
- slm/templates/slm/forms/widgets/auto_complete_multiple.html +8 -7
- slm/templates/slm/station/download.html +6 -6
- slm/templates/slm/station/edit.html +9 -17
- slm/templates/slm/station/review.html +5 -3
- slm/templates/slm/station/upload.html +4 -1
- slm/templates/slm/station/uploads/legacy.html +1 -1
- slm/templates/slm/widgets/alert_scroll.html +4 -8
- slm/templates/slm/widgets/filelist.html +0 -5
- slm/templates/slm/widgets/log_scroll.html +2 -13
- slm/templates/slm/widgets/stationlist.html +2 -8
- slm/templatetags/slm.py +70 -9
- slm/utils.py +13 -4
- slm/validators.py +14 -14
- slm/views.py +6 -6
- slm/wsgi.py +16 -0
- igs_slm-0.1.2b0.dist-info/METADATA +0 -151
- igs_slm-0.1.2b0.dist-info/entry_points.txt +0 -3
- slm/bin/templates/{{ project_dir }}/sites/{{ site }}/validation.py +0 -11
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/local.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/develop/wsgi.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/manage.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/production/wsgi.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{sites → src/sites}/{{ site }}/urls.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/admin.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/apps.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/commands/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/management/commands/import_archive.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/migrations/__init__.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/models.py +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/templates/slm/base.html +0 -0
- /slm/bin/templates/{{ project_dir }}/{{{ extension_app }} → src/{{ extension_app }}}/urls.py +0 -0
- /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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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 =
|
|
23
|
-
|
|
24
|
-
|
|
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/
|
|
28
|
-
|
|
29
|
-
ALLOWED_HOSTS =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
|
190
|
+
set_default("STATIC_URL", "/static/")
|
|
115
191
|
|
|
116
192
|
# Default primary key field type
|
|
117
|
-
# https://docs.djangoproject.com/en/
|
|
193
|
+
# https://docs.djangoproject.com/en/stable/ref/settings/#default-auto-field
|
|
118
194
|
|
|
119
|
-
DEFAULT_AUTO_FIELD
|
|
195
|
+
set_default("DEFAULT_AUTO_FIELD", "django.db.models.BigAutoField")
|
|
120
196
|
|
|
121
197
|
set_default("SITE_ID", 1)
|
|
122
198
|
|
|
123
|
-
STATIC_ROOT =
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
include("
|
|
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
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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",
|
|
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(
|
|
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
|
+
# )
|
slm/settings/static_templates.py
CHANGED
|
@@ -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
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
)
|