We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Development server not starting when GVZ API not reachable
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
When the [GVZ API](http://gvz.integreat-app.de/api/search/expect_empty_json) is reachable, but does not answer, the development server hangs during start, because there is no timeout defined for the api request [here](https://github.com/Integreat/cms-django/blob/f4f4c698575e975655b1333f630b5f0d6e4e034f/src/gvz_api/apps.py#L27).

### Steps to Reproduce

1. Execute `./dev-tools/run.sh` when GVZ API is reachable but does not answer (tested this morning)
2. Wait

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
The server should start and print a log message that the gvz api is not available

### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
The server does not start

### Additional Information
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->


Development server not starting when GVZ API not reachable
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
When the [GVZ API](http://gvz.integreat-app.de/api/search/expect_empty_json) is reachable, but does not answer, the development server hangs during start, because there is no timeout defined for the api request [here](https://github.com/Integreat/cms-django/blob/f4f4c698575e975655b1333f630b5f0d6e4e034f/src/gvz_api/apps.py#L27).

### Steps to Reproduce

1. Execute `./dev-tools/run.sh` when GVZ API is reachable but does not answer (tested this morning)
2. Wait

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
The server should start and print a log message that the gvz api is not available

### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
The server does not start

### Additional Information
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/gvz_api/apps.py`
Content:
```
1 """
2 Configuration of GVZ API app
3 """
4 import logging
5 import json
6 import requests
7 from django.apps import AppConfig
8 from django.conf import settings
9 
10 logger = logging.getLogger(__name__)
11 
12 
13 class GvzApiConfig(AppConfig):
14     """
15     GVZ API config inheriting the django AppConfig
16     """
17 
18     name = "gvz_api"
19     api_available = False
20 
21     def ready(self):
22         """
23         Checking if API is available
24         """
25         if settings.GVZ_API_ENABLED:
26             try:
27                 response = requests.get(
28                     f"{settings.GVZ_API_URL}/search/expect_empty_json"
29                 )
30                 json.loads(response.text)
31             except json.decoder.JSONDecodeError:
32                 self.api_available = False
33             except requests.exceptions.RequestException:
34                 self.api_available = False
35             else:
36                 self.api_available = True
37         else:
38             self.api_available = False
39         if not self.api_available:
40             logger.info(
41                 "GVZ API is not available. You won't be able to "
42                 "automatically import coordinates and region aliases."
43             )
44         else:
45             self.api_available = True
46             logger.info("GVZ API is available.")
47
```

Path: `src/backend/settings.py`
Content:
```
1 """
2 Django settings for backend project.
3 
4 For more information on this file, see :doc:`topics/settings`.
5 For the full list of settings and their values, see :doc:`ref/settings`.
6 """
7 import os
8 
9 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
10 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
11 
12 
13 # Version number
14 VERSION = "0.0.14"
15 
16 # Quick-start development settings - unsuitable for production
17 # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
18 
19 # SECURITY WARNING: keep the secret key used in production secret!
20 SECRET_KEY = "-!v282$zj815_q@htaxcubylo)(l%a+k*-xi78hw*#s2@i86@_"
21 
22 # SECURITY WARNING: don't run with debug turned on in production!
23 DEBUG = True
24 
25 ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0"]
26 
27 # Needed for webauthn (this is a setting in case the application runs behind a proxy)
28 HOSTNAME = "localhost"
29 BASE_URL = "http://localhost:8000"
30 
31 # Application definition
32 
33 INSTALLED_APPS = [
34     "cms.apps.CmsConfig",
35     "gvz_api.apps.GvzApiConfig",
36     "django.contrib.admin",
37     "django.contrib.auth",
38     "django.contrib.contenttypes",
39     "django.contrib.messages",
40     "django.contrib.sessions",
41     "django.contrib.staticfiles",
42     "compressor",
43     "compressor_toolkit",
44     "corsheaders",
45     "widget_tweaks",
46     "easy_thumbnails",
47     "filer",
48     "mptt",
49     "rules.apps.AutodiscoverRulesConfig",
50 ]
51 
52 MIDDLEWARE = [
53     "corsheaders.middleware.CorsMiddleware",
54     "django.middleware.security.SecurityMiddleware",
55     "django.contrib.sessions.middleware.SessionMiddleware",
56     "django.middleware.locale.LocaleMiddleware",
57     "django.middleware.common.CommonMiddleware",
58     "django.middleware.csrf.CsrfViewMiddleware",
59     "django.contrib.auth.middleware.AuthenticationMiddleware",
60     "django.contrib.messages.middleware.MessageMiddleware",
61     "django.middleware.clickjacking.XFrameOptionsMiddleware",
62 ]
63 
64 ROOT_URLCONF = "backend.urls"
65 THUMBNAIL_HIGH_RESOLUTION = True
66 
67 TEMPLATES = [
68     {
69         "BACKEND": "django.template.backends.django.DjangoTemplates",
70         "DIRS": [],
71         "APP_DIRS": True,
72         "OPTIONS": {
73             "context_processors": [
74                 "django.template.context_processors.debug",
75                 "django.template.context_processors.request",
76                 "django.contrib.auth.context_processors.auth",
77                 "django.contrib.messages.context_processors.messages",
78                 "backend.context_processors.region_slug_processor",
79             ],
80             "debug": DEBUG,
81         },
82     },
83 ]
84 
85 WSGI_APPLICATION = "backend.wsgi.application"
86 
87 
88 # Database
89 # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
90 
91 DATABASES = {
92     "default": {
93         "ENGINE": "django.db.backends.postgresql_psycopg2",
94         "NAME": "integreat",
95         "USER": "integreat",
96         "PASSWORD": "password",
97         "HOST": "localhost",
98         "PORT": "5432",
99     }
100 }
101 
102 # Directory for initial database contents
103 
104 FIXTURE_DIRS = (os.path.join(BASE_DIR, "cms/fixtures/"),)
105 
106 # Authentication backends
107 
108 AUTHENTICATION_BACKENDS = (
109     "rules.permissions.ObjectPermissionBackend",
110     "django.contrib.auth.backends.ModelBackend",  # this is default
111 )
112 
113 
114 # Password validation
115 # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
116 
117 AUTH_PASSWORD_VALIDATORS = [
118     {
119         "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
120     },
121     {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
122     {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
123     {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
124 ]
125 
126 
127 # Internationalization
128 # https://docs.djangoproject.com/en/2.2/topics/i18n/
129 
130 LANGUAGES = (
131     ("en-us", "English"),
132     ("de-de", "Deutsch"),
133 )
134 
135 LOCALE_PATHS = (os.path.join(BASE_DIR, "locale"),)
136 
137 LANGUAGE_CODE = "de-de"
138 
139 TIME_ZONE = "UTC"
140 
141 USE_I18N = True
142 
143 USE_L10N = True
144 
145 USE_TZ = True
146 
147 
148 # Static files (CSS, JavaScript, Images)
149 # https://docs.djangoproject.com/en/2.2/howto/static-files/
150 
151 STATICFILES_DIRS = [
152     os.path.join(BASE_DIR, "../node_modules"),
153 ]
154 STATIC_URL = "/static/"
155 STATIC_ROOT = os.path.join(BASE_DIR, "cms/static/")
156 
157 # Login
158 LOGIN_URL = "/login"
159 LOGIN_REDIRECT_URL = "/"
160 LOGOUT_REDIRECT_URL = "/login"
161 
162 # Miscellaneous
163 EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
164 CSRF_FAILURE_VIEW = "cms.views.error_handler.csrf_failure"
165 
166 MEDIA_URL = "/media/"
167 MEDIA_ROOT = os.path.join(BASE_DIR, "media")
168 FILER_CANONICAL_URL = "media/"
169 
170 LOGGING = {
171     "version": 1,
172     "disable_existing_loggers": False,
173     "formatters": {
174         "default": {"format": "INTEGREAT CMS - %(levelname)s: %(message)s",},
175         "console": {
176             "format": "%(asctime)s INTEGREAT CMS - %(levelname)s: %(message)s",
177             "datefmt": "%b %d %H:%M:%S",
178         },
179     },
180     "handlers": {
181         "console": {"class": "logging.StreamHandler", "formatter": "console"},
182         "authlog": {
183             "level": "INFO",
184             "class": "logging.handlers.SysLogHandler",
185             "address": "/dev/log",
186             "facility": "auth",
187             "formatter": "default",
188         },
189         "syslog": {
190             "level": "INFO",
191             "class": "logging.handlers.SysLogHandler",
192             "address": "/dev/log",
193             "facility": "syslog",
194             "formatter": "default",
195         },
196     },
197     "loggers": {
198         "django": {"handlers": ["console"], "level": "WARN", "propagate": True,},
199         "api": {"handlers": ["console"], "level": "INFO", "propagate": True,},
200         "cms": {"handlers": ["console"], "level": "INFO", "propagate": True,},
201         "rules": {"handlers": ["console"], "level": "DEBUG", "propagate": True,},
202         "auth": {"handlers": ["console", "authlog", "syslog"], "level": "INFO",},
203     },
204 }
205 
206 STATICFILES_FINDERS = (
207     "django.contrib.staticfiles.finders.FileSystemFinder",
208     "django.contrib.staticfiles.finders.AppDirectoriesFinder",
209     "compressor.finders.CompressorFinder",
210 )
211 
212 COMPRESS_CSS_FILTERS = [
213     "compressor.filters.css_default.CssAbsoluteFilter",
214     "compressor.filters.cssmin.CSSMinFilter",
215     "compressor.filters.template.TemplateFilter",
216 ]
217 COMPRESS_JS_FILTERS = [
218     "compressor.filters.jsmin.JSMinFilter",
219 ]
220 COMPRESS_PRECOMPILERS = (
221     ("module", "compressor_toolkit.precompilers.ES6Compiler"),
222     ("css", "compressor_toolkit.precompilers.SCSSCompiler"),
223 )
224 COMPRESS_ENABLED = False
225 COMPRESS_OFFLINE = True
226 
227 # GVZ (Gemeindeverzeichnis) API URL
228 GVZ_API_URL = "http://gvz.integreat-app.de/api/"
229 GVZ_API_ENABLED = True
230 
231 # Allow access to all domains by setting the following variable to TRUE
232 CORS_ORIGIN_ALLOW_ALL = True
233 
234 # Extend default headers with development header to differenciate dev traffic in statistics
235 CORS_ALLOW_HEADERS = [
236     "accept",
237     "accept-encoding",
238     "authorization",
239     "content-type",
240     "dnt",
241     "origin",
242     "user-agent",
243     "x-csrftoken",
244     "x-requested-with",
245     "x-integreat-development",
246 ]
247
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/backend/settings.py b/src/backend/settings.py
--- a/src/backend/settings.py
+++ b/src/backend/settings.py
@@ -197,7 +197,9 @@
     "loggers": {
         "django": {"handlers": ["console"], "level": "WARN", "propagate": True,},
         "api": {"handlers": ["console"], "level": "INFO", "propagate": True,},
+        "backend": {"handlers": ["console"], "level": "INFO", "propagate": True,},
         "cms": {"handlers": ["console"], "level": "INFO", "propagate": True,},
+        "gvz_api": {"handlers": ["console"], "level": "INFO", "propagate": True,},
         "rules": {"handlers": ["console"], "level": "DEBUG", "propagate": True,},
         "auth": {"handlers": ["console", "authlog", "syslog"], "level": "INFO",},
     },
@@ -225,7 +227,7 @@
 COMPRESS_OFFLINE = True
 
 # GVZ (Gemeindeverzeichnis) API URL
-GVZ_API_URL = "http://gvz.integreat-app.de/api/"
+GVZ_API_URL = "https://gvz.integreat-app.de/api/"
 GVZ_API_ENABLED = True
 
 # Allow access to all domains by setting the following variable to TRUE
diff --git a/src/gvz_api/apps.py b/src/gvz_api/apps.py
--- a/src/gvz_api/apps.py
+++ b/src/gvz_api/apps.py
@@ -1,6 +1,7 @@
 """
 Configuration of GVZ API app
 """
+import sys
 import logging
 import json
 import requests
@@ -22,25 +23,25 @@
         """
         Checking if API is available
         """
-        if settings.GVZ_API_ENABLED:
-            try:
-                response = requests.get(
-                    f"{settings.GVZ_API_URL}/search/expect_empty_json"
-                )
-                json.loads(response.text)
-            except json.decoder.JSONDecodeError:
-                self.api_available = False
-            except requests.exceptions.RequestException:
-                self.api_available = False
+        # Only check availability if current command is "runserver"
+        if sys.argv[1] == "runserver":
+            if settings.GVZ_API_ENABLED:
+                try:
+                    response = requests.get(
+                        f"{settings.GVZ_API_URL}/search/expect_empty_json", timeout=3
+                    )
+                    json.loads(response.text)
+                except (
+                    json.decoder.JSONDecodeError,
+                    requests.exceptions.RequestException,
+                    requests.exceptions.Timeout,
+                ):
+                    logger.info(
+                        "GVZ API is not available. You won't be able to "
+                        "automatically import coordinates and region aliases."
+                    )
+                else:
+                    self.api_available = True
+                    logger.debug("GVZ API is available.")
             else:
-                self.api_available = True
-        else:
-            self.api_available = False
-        if not self.api_available:
-            logger.info(
-                "GVZ API is not available. You won't be able to "
-                "automatically import coordinates and region aliases."
-            )
-        else:
-            self.api_available = True
-            logger.info("GVZ API is available.")
+                logger.debug("GVZ API is not enabled.")

{"golden_diff": "diff --git a/src/backend/settings.py b/src/backend/settings.py\n--- a/src/backend/settings.py\n+++ b/src/backend/settings.py\n@@ -197,7 +197,9 @@\n     \"loggers\": {\n         \"django\": {\"handlers\": [\"console\"], \"level\": \"WARN\", \"propagate\": True,},\n         \"api\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n+        \"backend\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n         \"cms\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n+        \"gvz_api\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n         \"rules\": {\"handlers\": [\"console\"], \"level\": \"DEBUG\", \"propagate\": True,},\n         \"auth\": {\"handlers\": [\"console\", \"authlog\", \"syslog\"], \"level\": \"INFO\",},\n     },\n@@ -225,7 +227,7 @@\n COMPRESS_OFFLINE = True\n \n # GVZ (Gemeindeverzeichnis) API URL\n-GVZ_API_URL = \"http://gvz.integreat-app.de/api/\"\n+GVZ_API_URL = \"https://gvz.integreat-app.de/api/\"\n GVZ_API_ENABLED = True\n \n # Allow access to all domains by setting the following variable to TRUE\ndiff --git a/src/gvz_api/apps.py b/src/gvz_api/apps.py\n--- a/src/gvz_api/apps.py\n+++ b/src/gvz_api/apps.py\n@@ -1,6 +1,7 @@\n \"\"\"\n Configuration of GVZ API app\n \"\"\"\n+import sys\n import logging\n import json\n import requests\n@@ -22,25 +23,25 @@\n         \"\"\"\n         Checking if API is available\n         \"\"\"\n-        if settings.GVZ_API_ENABLED:\n-            try:\n-                response = requests.get(\n-                    f\"{settings.GVZ_API_URL}/search/expect_empty_json\"\n-                )\n-                json.loads(response.text)\n-            except json.decoder.JSONDecodeError:\n-                self.api_available = False\n-            except requests.exceptions.RequestException:\n-                self.api_available = False\n+        # Only check availability if current command is \"runserver\"\n+        if sys.argv[1] == \"runserver\":\n+            if settings.GVZ_API_ENABLED:\n+                try:\n+                    response = requests.get(\n+                        f\"{settings.GVZ_API_URL}/search/expect_empty_json\", timeout=3\n+                    )\n+                    json.loads(response.text)\n+                except (\n+                    json.decoder.JSONDecodeError,\n+                    requests.exceptions.RequestException,\n+                    requests.exceptions.Timeout,\n+                ):\n+                    logger.info(\n+                        \"GVZ API is not available. You won't be able to \"\n+                        \"automatically import coordinates and region aliases.\"\n+                    )\n+                else:\n+                    self.api_available = True\n+                    logger.debug(\"GVZ API is available.\")\n             else:\n-                self.api_available = True\n-        else:\n-            self.api_available = False\n-        if not self.api_available:\n-            logger.info(\n-                \"GVZ API is not available. You won't be able to \"\n-                \"automatically import coordinates and region aliases.\"\n-            )\n-        else:\n-            self.api_available = True\n-            logger.info(\"GVZ API is available.\")\n+                logger.debug(\"GVZ API is not enabled.\")\n", "issue": "Development server not starting when GVZ API not reachable\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nWhen the [GVZ API](http://gvz.integreat-app.de/api/search/expect_empty_json) is reachable, but does not answer, the development server hangs during start, because there is no timeout defined for the api request [here](https://github.com/Integreat/cms-django/blob/f4f4c698575e975655b1333f630b5f0d6e4e034f/src/gvz_api/apps.py#L27).\r\n\r\n### Steps to Reproduce\r\n\r\n1. Execute `./dev-tools/run.sh` when GVZ API is reachable but does not answer (tested this morning)\r\n2. Wait\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nThe server should start and print a log message that the gvz api is not available\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nThe server does not start\r\n\r\n### Additional Information\r\n<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->\r\n\r\n\nDevelopment server not starting when GVZ API not reachable\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nWhen the [GVZ API](http://gvz.integreat-app.de/api/search/expect_empty_json) is reachable, but does not answer, the development server hangs during start, because there is no timeout defined for the api request [here](https://github.com/Integreat/cms-django/blob/f4f4c698575e975655b1333f630b5f0d6e4e034f/src/gvz_api/apps.py#L27).\r\n\r\n### Steps to Reproduce\r\n\r\n1. Execute `./dev-tools/run.sh` when GVZ API is reachable but does not answer (tested this morning)\r\n2. Wait\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nThe server should start and print a log message that the gvz api is not available\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nThe server does not start\r\n\r\n### Additional Information\r\n<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nConfiguration of GVZ API app\n\"\"\"\nimport logging\nimport json\nimport requests\nfrom django.apps import AppConfig\nfrom django.conf import settings\n\nlogger = logging.getLogger(__name__)\n\n\nclass GvzApiConfig(AppConfig):\n    \"\"\"\n    GVZ API config inheriting the django AppConfig\n    \"\"\"\n\n    name = \"gvz_api\"\n    api_available = False\n\n    def ready(self):\n        \"\"\"\n        Checking if API is available\n        \"\"\"\n        if settings.GVZ_API_ENABLED:\n            try:\n                response = requests.get(\n                    f\"{settings.GVZ_API_URL}/search/expect_empty_json\"\n                )\n                json.loads(response.text)\n            except json.decoder.JSONDecodeError:\n                self.api_available = False\n            except requests.exceptions.RequestException:\n                self.api_available = False\n            else:\n                self.api_available = True\n        else:\n            self.api_available = False\n        if not self.api_available:\n            logger.info(\n                \"GVZ API is not available. You won't be able to \"\n                \"automatically import coordinates and region aliases.\"\n            )\n        else:\n            self.api_available = True\n            logger.info(\"GVZ API is available.\")\n", "path": "src/gvz_api/apps.py"}, {"content": "\"\"\"\nDjango settings for backend project.\n\nFor more information on this file, see :doc:`topics/settings`.\nFor the full list of settings and their values, see :doc:`ref/settings`.\n\"\"\"\nimport os\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# Version number\nVERSION = \"0.0.14\"\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = \"-!v282$zj815_q@htaxcubylo)(l%a+k*-xi78hw*#s2@i86@_\"\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = True\n\nALLOWED_HOSTS = [\"localhost\", \"127.0.0.1\", \"0.0.0.0\"]\n\n# Needed for webauthn (this is a setting in case the application runs behind a proxy)\nHOSTNAME = \"localhost\"\nBASE_URL = \"http://localhost:8000\"\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"cms.apps.CmsConfig\",\n    \"gvz_api.apps.GvzApiConfig\",\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.messages\",\n    \"django.contrib.sessions\",\n    \"django.contrib.staticfiles\",\n    \"compressor\",\n    \"compressor_toolkit\",\n    \"corsheaders\",\n    \"widget_tweaks\",\n    \"easy_thumbnails\",\n    \"filer\",\n    \"mptt\",\n    \"rules.apps.AutodiscoverRulesConfig\",\n]\n\nMIDDLEWARE = [\n    \"corsheaders.middleware.CorsMiddleware\",\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.locale.LocaleMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"backend.urls\"\nTHUMBNAIL_HIGH_RESOLUTION = True\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n                \"backend.context_processors.region_slug_processor\",\n            ],\n            \"debug\": DEBUG,\n        },\n    },\n]\n\nWSGI_APPLICATION = \"backend.wsgi.application\"\n\n\n# Database\n# https://docs.djangoproject.com/en/2.2/ref/settings/#databases\n\nDATABASES = {\n    \"default\": {\n        \"ENGINE\": \"django.db.backends.postgresql_psycopg2\",\n        \"NAME\": \"integreat\",\n        \"USER\": \"integreat\",\n        \"PASSWORD\": \"password\",\n        \"HOST\": \"localhost\",\n        \"PORT\": \"5432\",\n    }\n}\n\n# Directory for initial database contents\n\nFIXTURE_DIRS = (os.path.join(BASE_DIR, \"cms/fixtures/\"),)\n\n# Authentication backends\n\nAUTHENTICATION_BACKENDS = (\n    \"rules.permissions.ObjectPermissionBackend\",\n    \"django.contrib.auth.backends.ModelBackend\",  # this is default\n)\n\n\n# Password validation\n# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",},\n    {\"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",},\n    {\"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",},\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/2.2/topics/i18n/\n\nLANGUAGES = (\n    (\"en-us\", \"English\"),\n    (\"de-de\", \"Deutsch\"),\n)\n\nLOCALE_PATHS = (os.path.join(BASE_DIR, \"locale\"),)\n\nLANGUAGE_CODE = \"de-de\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/2.2/howto/static-files/\n\nSTATICFILES_DIRS = [\n    os.path.join(BASE_DIR, \"../node_modules\"),\n]\nSTATIC_URL = \"/static/\"\nSTATIC_ROOT = os.path.join(BASE_DIR, \"cms/static/\")\n\n# Login\nLOGIN_URL = \"/login\"\nLOGIN_REDIRECT_URL = \"/\"\nLOGOUT_REDIRECT_URL = \"/login\"\n\n# Miscellaneous\nEMAIL_BACKEND = \"django.core.mail.backends.console.EmailBackend\"\nCSRF_FAILURE_VIEW = \"cms.views.error_handler.csrf_failure\"\n\nMEDIA_URL = \"/media/\"\nMEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nFILER_CANONICAL_URL = \"media/\"\n\nLOGGING = {\n    \"version\": 1,\n    \"disable_existing_loggers\": False,\n    \"formatters\": {\n        \"default\": {\"format\": \"INTEGREAT CMS - %(levelname)s: %(message)s\",},\n        \"console\": {\n            \"format\": \"%(asctime)s INTEGREAT CMS - %(levelname)s: %(message)s\",\n            \"datefmt\": \"%b %d %H:%M:%S\",\n        },\n    },\n    \"handlers\": {\n        \"console\": {\"class\": \"logging.StreamHandler\", \"formatter\": \"console\"},\n        \"authlog\": {\n            \"level\": \"INFO\",\n            \"class\": \"logging.handlers.SysLogHandler\",\n            \"address\": \"/dev/log\",\n            \"facility\": \"auth\",\n            \"formatter\": \"default\",\n        },\n        \"syslog\": {\n            \"level\": \"INFO\",\n            \"class\": \"logging.handlers.SysLogHandler\",\n            \"address\": \"/dev/log\",\n            \"facility\": \"syslog\",\n            \"formatter\": \"default\",\n        },\n    },\n    \"loggers\": {\n        \"django\": {\"handlers\": [\"console\"], \"level\": \"WARN\", \"propagate\": True,},\n        \"api\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"cms\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"rules\": {\"handlers\": [\"console\"], \"level\": \"DEBUG\", \"propagate\": True,},\n        \"auth\": {\"handlers\": [\"console\", \"authlog\", \"syslog\"], \"level\": \"INFO\",},\n    },\n}\n\nSTATICFILES_FINDERS = (\n    \"django.contrib.staticfiles.finders.FileSystemFinder\",\n    \"django.contrib.staticfiles.finders.AppDirectoriesFinder\",\n    \"compressor.finders.CompressorFinder\",\n)\n\nCOMPRESS_CSS_FILTERS = [\n    \"compressor.filters.css_default.CssAbsoluteFilter\",\n    \"compressor.filters.cssmin.CSSMinFilter\",\n    \"compressor.filters.template.TemplateFilter\",\n]\nCOMPRESS_JS_FILTERS = [\n    \"compressor.filters.jsmin.JSMinFilter\",\n]\nCOMPRESS_PRECOMPILERS = (\n    (\"module\", \"compressor_toolkit.precompilers.ES6Compiler\"),\n    (\"css\", \"compressor_toolkit.precompilers.SCSSCompiler\"),\n)\nCOMPRESS_ENABLED = False\nCOMPRESS_OFFLINE = True\n\n# GVZ (Gemeindeverzeichnis) API URL\nGVZ_API_URL = \"http://gvz.integreat-app.de/api/\"\nGVZ_API_ENABLED = True\n\n# Allow access to all domains by setting the following variable to TRUE\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Extend default headers with development header to differenciate dev traffic in statistics\nCORS_ALLOW_HEADERS = [\n    \"accept\",\n    \"accept-encoding\",\n    \"authorization\",\n    \"content-type\",\n    \"dnt\",\n    \"origin\",\n    \"user-agent\",\n    \"x-csrftoken\",\n    \"x-requested-with\",\n    \"x-integreat-development\",\n]\n", "path": "src/backend/settings.py"}], "after_files": [{"content": "\"\"\"\nConfiguration of GVZ API app\n\"\"\"\nimport sys\nimport logging\nimport json\nimport requests\nfrom django.apps import AppConfig\nfrom django.conf import settings\n\nlogger = logging.getLogger(__name__)\n\n\nclass GvzApiConfig(AppConfig):\n    \"\"\"\n    GVZ API config inheriting the django AppConfig\n    \"\"\"\n\n    name = \"gvz_api\"\n    api_available = False\n\n    def ready(self):\n        \"\"\"\n        Checking if API is available\n        \"\"\"\n        # Only check availability if current command is \"runserver\"\n        if sys.argv[1] == \"runserver\":\n            if settings.GVZ_API_ENABLED:\n                try:\n                    response = requests.get(\n                        f\"{settings.GVZ_API_URL}/search/expect_empty_json\", timeout=3\n                    )\n                    json.loads(response.text)\n                except (\n                    json.decoder.JSONDecodeError,\n                    requests.exceptions.RequestException,\n                    requests.exceptions.Timeout,\n                ):\n                    logger.info(\n                        \"GVZ API is not available. You won't be able to \"\n                        \"automatically import coordinates and region aliases.\"\n                    )\n                else:\n                    self.api_available = True\n                    logger.debug(\"GVZ API is available.\")\n            else:\n                logger.debug(\"GVZ API is not enabled.\")\n", "path": "src/gvz_api/apps.py"}, {"content": "\"\"\"\nDjango settings for backend project.\n\nFor more information on this file, see :doc:`topics/settings`.\nFor the full list of settings and their values, see :doc:`ref/settings`.\n\"\"\"\nimport os\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# Version number\nVERSION = \"0.0.14\"\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = \"-!v282$zj815_q@htaxcubylo)(l%a+k*-xi78hw*#s2@i86@_\"\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = True\n\nALLOWED_HOSTS = [\"localhost\", \"127.0.0.1\", \"0.0.0.0\"]\n\n# Needed for webauthn (this is a setting in case the application runs behind a proxy)\nHOSTNAME = \"localhost\"\nBASE_URL = \"http://localhost:8000\"\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"cms.apps.CmsConfig\",\n    \"gvz_api.apps.GvzApiConfig\",\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.messages\",\n    \"django.contrib.sessions\",\n    \"django.contrib.staticfiles\",\n    \"compressor\",\n    \"compressor_toolkit\",\n    \"corsheaders\",\n    \"widget_tweaks\",\n    \"easy_thumbnails\",\n    \"filer\",\n    \"mptt\",\n    \"rules.apps.AutodiscoverRulesConfig\",\n]\n\nMIDDLEWARE = [\n    \"corsheaders.middleware.CorsMiddleware\",\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.locale.LocaleMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"backend.urls\"\nTHUMBNAIL_HIGH_RESOLUTION = True\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n                \"backend.context_processors.region_slug_processor\",\n            ],\n            \"debug\": DEBUG,\n        },\n    },\n]\n\nWSGI_APPLICATION = \"backend.wsgi.application\"\n\n\n# Database\n# https://docs.djangoproject.com/en/2.2/ref/settings/#databases\n\nDATABASES = {\n    \"default\": {\n        \"ENGINE\": \"django.db.backends.postgresql_psycopg2\",\n        \"NAME\": \"integreat\",\n        \"USER\": \"integreat\",\n        \"PASSWORD\": \"password\",\n        \"HOST\": \"localhost\",\n        \"PORT\": \"5432\",\n    }\n}\n\n# Directory for initial database contents\n\nFIXTURE_DIRS = (os.path.join(BASE_DIR, \"cms/fixtures/\"),)\n\n# Authentication backends\n\nAUTHENTICATION_BACKENDS = (\n    \"rules.permissions.ObjectPermissionBackend\",\n    \"django.contrib.auth.backends.ModelBackend\",  # this is default\n)\n\n\n# Password validation\n# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",},\n    {\"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",},\n    {\"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",},\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/2.2/topics/i18n/\n\nLANGUAGES = (\n    (\"en-us\", \"English\"),\n    (\"de-de\", \"Deutsch\"),\n)\n\nLOCALE_PATHS = (os.path.join(BASE_DIR, \"locale\"),)\n\nLANGUAGE_CODE = \"de-de\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/2.2/howto/static-files/\n\nSTATICFILES_DIRS = [\n    os.path.join(BASE_DIR, \"../node_modules\"),\n]\nSTATIC_URL = \"/static/\"\nSTATIC_ROOT = os.path.join(BASE_DIR, \"cms/static/\")\n\n# Login\nLOGIN_URL = \"/login\"\nLOGIN_REDIRECT_URL = \"/\"\nLOGOUT_REDIRECT_URL = \"/login\"\n\n# Miscellaneous\nEMAIL_BACKEND = \"django.core.mail.backends.console.EmailBackend\"\nCSRF_FAILURE_VIEW = \"cms.views.error_handler.csrf_failure\"\n\nMEDIA_URL = \"/media/\"\nMEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nFILER_CANONICAL_URL = \"media/\"\n\nLOGGING = {\n    \"version\": 1,\n    \"disable_existing_loggers\": False,\n    \"formatters\": {\n        \"default\": {\"format\": \"INTEGREAT CMS - %(levelname)s: %(message)s\",},\n        \"console\": {\n            \"format\": \"%(asctime)s INTEGREAT CMS - %(levelname)s: %(message)s\",\n            \"datefmt\": \"%b %d %H:%M:%S\",\n        },\n    },\n    \"handlers\": {\n        \"console\": {\"class\": \"logging.StreamHandler\", \"formatter\": \"console\"},\n        \"authlog\": {\n            \"level\": \"INFO\",\n            \"class\": \"logging.handlers.SysLogHandler\",\n            \"address\": \"/dev/log\",\n            \"facility\": \"auth\",\n            \"formatter\": \"default\",\n        },\n        \"syslog\": {\n            \"level\": \"INFO\",\n            \"class\": \"logging.handlers.SysLogHandler\",\n            \"address\": \"/dev/log\",\n            \"facility\": \"syslog\",\n            \"formatter\": \"default\",\n        },\n    },\n    \"loggers\": {\n        \"django\": {\"handlers\": [\"console\"], \"level\": \"WARN\", \"propagate\": True,},\n        \"api\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"backend\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"cms\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"gvz_api\": {\"handlers\": [\"console\"], \"level\": \"INFO\", \"propagate\": True,},\n        \"rules\": {\"handlers\": [\"console\"], \"level\": \"DEBUG\", \"propagate\": True,},\n        \"auth\": {\"handlers\": [\"console\", \"authlog\", \"syslog\"], \"level\": \"INFO\",},\n    },\n}\n\nSTATICFILES_FINDERS = (\n    \"django.contrib.staticfiles.finders.FileSystemFinder\",\n    \"django.contrib.staticfiles.finders.AppDirectoriesFinder\",\n    \"compressor.finders.CompressorFinder\",\n)\n\nCOMPRESS_CSS_FILTERS = [\n    \"compressor.filters.css_default.CssAbsoluteFilter\",\n    \"compressor.filters.cssmin.CSSMinFilter\",\n    \"compressor.filters.template.TemplateFilter\",\n]\nCOMPRESS_JS_FILTERS = [\n    \"compressor.filters.jsmin.JSMinFilter\",\n]\nCOMPRESS_PRECOMPILERS = (\n    (\"module\", \"compressor_toolkit.precompilers.ES6Compiler\"),\n    (\"css\", \"compressor_toolkit.precompilers.SCSSCompiler\"),\n)\nCOMPRESS_ENABLED = False\nCOMPRESS_OFFLINE = True\n\n# GVZ (Gemeindeverzeichnis) API URL\nGVZ_API_URL = \"https://gvz.integreat-app.de/api/\"\nGVZ_API_ENABLED = True\n\n# Allow access to all domains by setting the following variable to TRUE\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Extend default headers with development header to differenciate dev traffic in statistics\nCORS_ALLOW_HEADERS = [\n    \"accept\",\n    \"accept-encoding\",\n    \"authorization\",\n    \"content-type\",\n    \"dnt\",\n    \"origin\",\n    \"user-agent\",\n    \"x-csrftoken\",\n    \"x-requested-with\",\n    \"x-integreat-development\",\n]\n", "path": "src/backend/settings.py"}]}