17
17
from pathlib import Path
18
18
19
19
20
- def set_up_settings (service_name : str ):
20
+ def set_up_settings (service_base_dir : Path , service_name : str ):
21
21
"""Set up the settings for the service.
22
22
23
23
*This needs to be called before importing the CFL settings!*
@@ -27,12 +27,13 @@ def set_up_settings(service_name: str):
27
27
from codeforlife import set_up_settings
28
28
29
29
# Must set up settings before importing them!
30
- secrets = set_up_settings("example")
30
+ SECRETS = set_up_settings("example")
31
31
32
32
from codeforlife.settings import *
33
33
```
34
34
35
35
Args:
36
+ service_base_dir: The base directory of the service.
36
37
service_name: The name of the current service.
37
38
38
39
Returns:
@@ -59,6 +60,7 @@ def set_up_settings(service_name: str):
59
60
"You must set up the CFL settings before importing them."
60
61
)
61
62
63
+ os .environ ["SERVICE_BASE_DIR" ] = str (service_base_dir )
62
64
os .environ ["SERVICE_NAME" ] = service_name
63
65
64
66
os .environ .setdefault ("ENV" , "local" )
@@ -107,7 +109,7 @@ def set_up_settings(service_name: str):
107
109
# Build paths inside the project like this: BASE_DIR / 'subdir'.
108
110
BASE_DIR = Path (__file__ ).resolve ().parent
109
111
110
- secrets = set_up_settings (service_name = "contributor" )
112
+ SECRETS = set_up_settings (BASE_DIR , service_name = "contributor" )
111
113
112
114
# pylint: disable-next=wildcard-import,unused-wildcard-import,wrong-import-position
113
115
from codeforlife .settings import *
@@ -147,31 +149,26 @@ def set_up_settings(service_name: str):
147
149
# https://docs.djangoproject.com/en/3.2/howto/static-files/
148
150
149
151
# TODO: move to cfl package and create helper functions.
150
- # STATIC_ROOT = get_static_root(BASE_DIR)
151
- STATIC_ROOT = os .getenv ("STATIC_ROOT" , BASE_DIR / "static" )
152
+ STATIC_ROOT = Path (os .environ ["SERVICE_BASE_DIR" ]) / "static"
152
153
STATIC_URL = os .getenv ("STATIC_URL" , "/static/" )
153
- STATICFILES_DIRS = (
154
- os .environ ["STATICFILES_DIRS" ].split ("," )
155
- if os .getenv ("STATICFILES_DIRS" )
156
- else []
157
- )
154
+
158
155
159
156
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
160
157
AWS_STORAGE_BUCKET_NAME = os .getenv ("AWS_STORAGE_BUCKET_NAME" )
161
158
162
- AWS_S3_CUSTOM_DOMAIN = os .getenv ("AWS_S3_CUSTOM_DOMAIN" )
163
- if AWS_S3_CUSTOM_DOMAIN == "" :
164
- AWS_S3_CUSTOM_DOMAIN = None
165
- AWS_LOCATION = os .getenv ("AWS_LOCATION" , "" )
166
- AWS_DEFAULT_ACL = os .getenv ("AWS_DEFAULT_ACL" )
167
- if AWS_DEFAULT_ACL == "" :
168
- AWS_DEFAULT_ACL = None
169
- AWS_S3_ADDRESSING_STYLE = os .getenv ("AWS_S3_ADDRESSING_STYLE" )
170
- if AWS_S3_ADDRESSING_STYLE == "" :
171
- AWS_S3_ADDRESSING_STYLE = None
172
- AWS_S3_REGION_NAME = os .getenv ("AWS_S3_REGION_NAME" )
173
- if AWS_S3_REGION_NAME == "" :
174
- AWS_S3_REGION_NAME = None
159
+ # AWS_S3_CUSTOM_DOMAIN = os.getenv("AWS_S3_CUSTOM_DOMAIN")
160
+ # if AWS_S3_CUSTOM_DOMAIN == "":
161
+ # AWS_S3_CUSTOM_DOMAIN = None
162
+ # AWS_LOCATION = os.getenv("AWS_LOCATION", "")
163
+ # AWS_DEFAULT_ACL = os.getenv("AWS_DEFAULT_ACL")
164
+ # if AWS_DEFAULT_ACL == "":
165
+ # AWS_DEFAULT_ACL = None
166
+ # AWS_S3_ADDRESSING_STYLE = os.getenv("AWS_S3_ADDRESSING_STYLE")
167
+ # if AWS_S3_ADDRESSING_STYLE == "":
168
+ # AWS_S3_ADDRESSING_STYLE = None
169
+ # AWS_S3_REGION_NAME = os.getenv("AWS_S3_REGION_NAME")
170
+ # if AWS_S3_REGION_NAME == "":
171
+ # AWS_S3_REGION_NAME = None
175
172
if AWS_STORAGE_BUCKET_NAME :
176
173
if "storages" not in INSTALLED_APPS :
177
174
INSTALLED_APPS .append ("storages" )
0 commit comments