From ff5d20989560069372bdc73d36d505e8280d4140 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Mon, 31 Jan 2022 15:09:06 +0100 Subject: [PATCH 1/2] #95 Split settings file * splits konova/settings.py file into more separate setting files in konova/sub_settings/ --- konova/settings.py | 63 +++------------------- konova/sub_settings/lanis_settings.py | 29 ++++++++++ konova/sub_settings/proxy_settings.py | 13 +++++ konova/sub_settings/sso_settings.py | 13 +++++ konova/sub_settings/table_settings.py | 24 +++++++++ konova/sub_settings/wfs_parcel_settings.py | 12 +++++ 6 files changed, 98 insertions(+), 56 deletions(-) create mode 100644 konova/sub_settings/lanis_settings.py create mode 100644 konova/sub_settings/proxy_settings.py create mode 100644 konova/sub_settings/sso_settings.py create mode 100644 konova/sub_settings/table_settings.py create mode 100644 konova/sub_settings/wfs_parcel_settings.py diff --git a/konova/settings.py b/konova/settings.py index 05199de1..dfd6195a 100644 --- a/konova/settings.py +++ b/konova/settings.py @@ -11,14 +11,15 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ from django.utils.translation import gettext_lazy as _ -# Load other settings +# Load sub settings +# If new settings need to be added as general settings to the whole project, outsource them into new xy_settings files! from konova.sub_settings.django_settings import * +from konova.sub_settings.proxy_settings import * +from konova.sub_settings.sso_settings import * +from konova.sub_settings.table_settings import * +from konova.sub_settings.lanis_settings import * +from konova.sub_settings.wfs_parcel_settings import * -proxy = "CHANGE_ME" -PROXIES = { - "http": proxy, - "https": proxy, -} # ALLOWED FILE UPLOAD DEFINITIONS # Default: Upload into upper folder of code @@ -37,57 +38,7 @@ EMA_DOC_PATH = BASE_DOC_PATH + "ema/{}/" # German DateTime string format STRF_DATE_TIME = "%d.%m.%Y %H:%M:%S" -# Tables -RESULTS_PER_PAGE_PARAM = "rpp" -PAGE_PARAM = "page" -PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 50, 100] -PAGE_SIZE_OPTIONS_TUPLES = [ - (5, 5), - (10, 10), - (15, 15), - (20, 20), - (25, 25), - (50, 50), - (100, 100), -] -PAGE_SIZE_DEFAULT = 5 -PAGE_SIZE_MAX = 100 -PAGE_DEFAULT = 1 - -# SSO settings -SSO_SERVER_BASE = "http://127.0.0.1:8000/" -SSO_SERVER = f"{SSO_SERVER_BASE}sso/" -SSO_PRIVATE_KEY = "QuziFeih7U8DZvQQ1riPv2MXz0ZABupHED9wjoqZAqeMQaqkqTfxJDRXgSIyASwJ" -SSO_PUBLIC_KEY = "AGGK7E8eT5X5u2GD38ygGG3GpAefmIldJiiWW7gldRPqCG1CzmUfGdvPSGDbEY2n" - -# MAPS -DEFAULT_LAT = 50.00 -DEFAULT_LON = 7.00 -DEFAULT_ZOOM = 8.0 -DEFAULT_SRID = 4326 -DEFAULT_SRID_RLP = 25832 - # GROUPS DEFAULT_GROUP = "Default" ZB_GROUP = "Registration office" ETS_GROUP = "Conservation office" - -# Needed to redirect to LANIS -## Values to be inserted are [zoom_level, x_coord, y_coord] -LANIS_LINK_TEMPLATE = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/index.php?lang=de&zl={}&x={}&y={}&bl=tk_rlp_tms_grau&bo=1&lo=0.8,0.8,0.8,0.6,0.8,0.8,0.8,0.8,0.8&layers=eiv_f,eiv_l,eiv_p,kom_f,kom_l,kom_p,oek_f,ema_f,mae&service=kartendienste_naturschutz" -## This look up table (LUT) defines different zoom levels on the size of the calculate area of a geometry. -LANIS_ZOOM_LUT = { - 1000000000: 6, - 100000000: 10, - 10000000: 17, - 1000000: 20, - 100000: 25, - 10000: 28, - 1000: 30, - 500: 31, -} - -# Parcel WFS settings -PARCEL_WFS_BASE_URL = "https://www.geoportal.rlp.de/registry/wfs/519" -PARCEL_WFS_USER = "ksp" -PARCEL_WFS_PW = "CHANGE_ME" \ No newline at end of file diff --git a/konova/sub_settings/lanis_settings.py b/konova/sub_settings/lanis_settings.py new file mode 100644 index 00000000..ac3610b5 --- /dev/null +++ b/konova/sub_settings/lanis_settings.py @@ -0,0 +1,29 @@ +""" +Author: Michel Peltriaux +Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany +Contact: michel.peltriaux@sgdnord.rlp.de +Created on: 31.01.22 + +""" + +# MAPS +DEFAULT_LAT = 50.00 +DEFAULT_LON = 7.00 +DEFAULT_ZOOM = 8.0 +DEFAULT_SRID = 4326 +DEFAULT_SRID_RLP = 25832 + +# Needed to redirect to LANIS +## Values to be inserted are [zoom_level, x_coord, y_coord] +LANIS_LINK_TEMPLATE = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/index.php?lang=de&zl={}&x={}&y={}&bl=tk_rlp_tms_grau&bo=1&lo=0.8,0.8,0.8,0.6,0.8,0.8,0.8,0.8,0.8&layers=eiv_f,eiv_l,eiv_p,kom_f,kom_l,kom_p,oek_f,ema_f,mae&service=kartendienste_naturschutz" +## This look up table (LUT) defines different zoom levels on the size of the calculate area of a geometry. +LANIS_ZOOM_LUT = { + 1000000000: 6, + 100000000: 10, + 10000000: 17, + 1000000: 20, + 100000: 25, + 10000: 28, + 1000: 30, + 500: 31, +} diff --git a/konova/sub_settings/proxy_settings.py b/konova/sub_settings/proxy_settings.py new file mode 100644 index 00000000..4867af10 --- /dev/null +++ b/konova/sub_settings/proxy_settings.py @@ -0,0 +1,13 @@ +""" +Author: Michel Peltriaux +Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany +Contact: michel.peltriaux@sgdnord.rlp.de +Created on: 31.01.22 + +""" + +proxy = "" +PROXIES = { + "http": proxy, + "https": proxy, +} \ No newline at end of file diff --git a/konova/sub_settings/sso_settings.py b/konova/sub_settings/sso_settings.py new file mode 100644 index 00000000..20417f04 --- /dev/null +++ b/konova/sub_settings/sso_settings.py @@ -0,0 +1,13 @@ +""" +Author: Michel Peltriaux +Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany +Contact: michel.peltriaux@sgdnord.rlp.de +Created on: 31.01.22 + +""" + +# SSO settings +SSO_SERVER_BASE = "http://127.0.0.1:8000/" +SSO_SERVER = f"{SSO_SERVER_BASE}sso/" +SSO_PRIVATE_KEY = "QuziFeih7U8DZvQQ1riPv2MXz0ZABupHED9wjoqZAqeMQaqkqTfxJDRXgSIyASwJ" +SSO_PUBLIC_KEY = "AGGK7E8eT5X5u2GD38ygGG3GpAefmIldJiiWW7gldRPqCG1CzmUfGdvPSGDbEY2n" \ No newline at end of file diff --git a/konova/sub_settings/table_settings.py b/konova/sub_settings/table_settings.py new file mode 100644 index 00000000..f32a0835 --- /dev/null +++ b/konova/sub_settings/table_settings.py @@ -0,0 +1,24 @@ +""" +Author: Michel Peltriaux +Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany +Contact: michel.peltriaux@sgdnord.rlp.de +Created on: 31.01.22 + +""" + +# Tables +RESULTS_PER_PAGE_PARAM = "rpp" +PAGE_PARAM = "page" +PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 50, 100] +PAGE_SIZE_OPTIONS_TUPLES = [ + (5, 5), + (10, 10), + (15, 15), + (20, 20), + (25, 25), + (50, 50), + (100, 100), +] +PAGE_SIZE_DEFAULT = 5 +PAGE_SIZE_MAX = 100 +PAGE_DEFAULT = 1 diff --git a/konova/sub_settings/wfs_parcel_settings.py b/konova/sub_settings/wfs_parcel_settings.py new file mode 100644 index 00000000..37744a70 --- /dev/null +++ b/konova/sub_settings/wfs_parcel_settings.py @@ -0,0 +1,12 @@ +""" +Author: Michel Peltriaux +Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany +Contact: michel.peltriaux@sgdnord.rlp.de +Created on: 31.01.22 + +""" + +# Parcel WFS settings +PARCEL_WFS_BASE_URL = "https://www.geoportal.rlp.de/registry/wfs/519" +PARCEL_WFS_USER = "ksp" +PARCEL_WFS_PW = "CHANGE_ME" \ No newline at end of file From f9751d38dba3a27424cdd6c12e0d20fd650389d7 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Mon, 31 Jan 2022 15:24:26 +0100 Subject: [PATCH 2/2] #93 Errors via mail * configures server errors sending via mail * default for now is always 'ksp-servicestelle' * includes improvements from #97 --- konova/sub_settings/django_settings.py | 44 ++++--------------- konova/utils/mailer.py | 4 -- logs/error.log | 0 .../email/checking/shared_data_checked.html | 2 +- .../email/deleting/shared_data_deleted.html | 2 +- .../email/recording/shared_data_recorded.html | 2 +- .../recording/shared_data_unrecorded.html | 2 +- .../email/sharing/shared_access_given.html | 2 +- .../email/sharing/shared_access_removed.html | 2 +- 9 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 logs/error.log diff --git a/konova/sub_settings/django_settings.py b/konova/sub_settings/django_settings.py index 84039b59..b0d6ff8a 100644 --- a/konova/sub_settings/django_settings.py +++ b/konova/sub_settings/django_settings.py @@ -32,6 +32,10 @@ SECRET_KEY = '5=9-)2)h$u9=!zrhia9=lj-2#cpcb8=#$7y+)l$5tto$3q(n_+' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +ADMINS = [ + ('KSP-Servicestelle', 'ksp-servicestelle@sgdnord.rlp.de'), +] + ALLOWED_HOSTS = [ "127.0.0.1", "localhost", @@ -207,10 +211,12 @@ DEBUG_TOOLBAR_CONFIG = { # EMAIL (see https://docs.djangoproject.com/en/dev/topics/email/) # CHANGE_ME !!! ONLY FOR DEVELOPMENT !!! -EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' -EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location +if DEBUG: + EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' + EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location DEFAULT_FROM_EMAIL = "service@ksp.de" # The default email address for the 'from' element +SERVER_EMAIL = DEFAULT_FROM_EMAIL # The default email sender address, which is used by Django to send errors via mail EMAIL_HOST = "localhost" EMAIL_REPLY_TO = "ksp-servicestelle@sgdnord.rlp.de" SUPPORT_MAIL_RECIPIENT = EMAIL_REPLY_TO @@ -219,37 +225,3 @@ EMAIL_PORT = "25" #EMAIL_HOST_PASSWORD = "" EMAIL_USE_TLS = False EMAIL_USE_SSL = False - -# LOGGING -BASIC_LOGGER = "logger" -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'verbose': { - 'format': '{levelname} {asctime} {module}: {message}', - 'style': '{', - }, - 'simple': { - 'format': '{levelname} {message}', - 'style': '{', - }, - }, - 'handlers': { - 'log_to_file': { - 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': '{}/logs/error.log'.format(BASE_DIR), - 'maxBytes': 1024*1024*5, # 5 MB - 'backupCount': 5, - 'formatter': 'verbose', - }, - }, - 'loggers': { - BASIC_LOGGER: { - 'handlers': ['log_to_file'], - 'level': 'INFO', - 'propagate': True, - }, - }, -} \ No newline at end of file diff --git a/konova/utils/mailer.py b/konova/utils/mailer.py index ee0ac9e5..e174ae56 100644 --- a/konova/utils/mailer.py +++ b/konova/utils/mailer.py @@ -5,16 +5,12 @@ Contact: michel.peltriaux@sgdnord.rlp.de Created on: 09.11.20 """ -import logging - from django.core.mail import send_mail from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ from konova.sub_settings.django_settings import DEFAULT_FROM_EMAIL, EMAIL_REPLY_TO, SUPPORT_MAIL_RECIPIENT -logger = logging.getLogger(__name__) - class Mailer: """ diff --git a/logs/error.log b/logs/error.log deleted file mode 100644 index e69de29b..00000000 diff --git a/templates/email/checking/shared_data_checked.html b/templates/email/checking/shared_data_checked.html index ccc0bbf3..0707cfbc 100644 --- a/templates/email/checking/shared_data_checked.html +++ b/templates/email/checking/shared_data_checked.html @@ -9,7 +9,7 @@
{% trans 'the following dataset has just been checked' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'This means, the responsible registration office just confirmed the correctness of this dataset.' %}
diff --git a/templates/email/deleting/shared_data_deleted.html b/templates/email/deleting/shared_data_deleted.html index 36c80b09..b920f1ec 100644 --- a/templates/email/deleting/shared_data_deleted.html +++ b/templates/email/deleting/shared_data_deleted.html @@ -9,7 +9,7 @@
{% trans 'the following dataset has just been deleted' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'If this should not have been happened, please contact us. See the signature for details.' %}
diff --git a/templates/email/recording/shared_data_recorded.html b/templates/email/recording/shared_data_recorded.html index 82d236d8..f8db9182 100644 --- a/templates/email/recording/shared_data_recorded.html +++ b/templates/email/recording/shared_data_recorded.html @@ -9,7 +9,7 @@
{% trans 'the following dataset has just been recorded' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'This means the data is now publicly available, e.g. in LANIS' %}
diff --git a/templates/email/recording/shared_data_unrecorded.html b/templates/email/recording/shared_data_unrecorded.html index a40e7ce8..d4639c9e 100644 --- a/templates/email/recording/shared_data_unrecorded.html +++ b/templates/email/recording/shared_data_unrecorded.html @@ -9,7 +9,7 @@
{% trans 'the following dataset has just been unrecorded' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'This means the data is no longer publicly available.' %}
diff --git a/templates/email/sharing/shared_access_given.html b/templates/email/sharing/shared_access_given.html index bf93e863..b8b26b7a 100644 --- a/templates/email/sharing/shared_access_given.html +++ b/templates/email/sharing/shared_access_given.html @@ -9,7 +9,7 @@
{% trans 'the following dataset has just been shared with you' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'This means you can now edit this dataset.' %} {% trans 'The shared dataset appears now by default on your overview for this dataset type.' %} diff --git a/templates/email/sharing/shared_access_removed.html b/templates/email/sharing/shared_access_removed.html index be6a4d6c..86d4fddd 100644 --- a/templates/email/sharing/shared_access_removed.html +++ b/templates/email/sharing/shared_access_removed.html @@ -9,7 +9,7 @@
{% trans 'your shared access, including editing, has been revoked for the dataset ' %}
- '{{obj_identifier}}' + {{obj_identifier}}
{% trans 'However, you are still able to view the dataset content.' %} {% trans 'Please use the provided search filter on the dataset`s overview pages to find them.' %}