Skip to content

Commit

Permalink
Create empty local_settings.py if none exsits
Browse files Browse the repository at this point in the history
simplify Dockerfile and remove useless warnings in development
  • Loading branch information
KevinMind committed Feb 19, 2024
1 parent 5c02123 commit 31e06f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ RUN ln -s ${HOME}/package.json /deps/package.json \
WORKDIR ${HOME}

# Build locales, assets, build id.
RUN echo "from olympia.lib.settings_base import *\n" \
> settings_local.py && DJANGO_SETTINGS_MODULE='settings_local' locale/compile-mo.sh locale \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py compress_assets \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py generate_jsi18n_files \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py collectstatic --noinput \
RUN locale/compile-mo.sh locale \
&& python manage.py compress_assets \
&& python manage.py generate_jsi18n_files \
&& python manage.py collectstatic --noinput \
&& npm prune --production \
&& ./scripts/generate_build.py > build.py \
&& rm -f settings_local.py settings_local.pyc
&& ./scripts/generate_build.py > build.py
21 changes: 10 additions & 11 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,16 @@ def insert_debug_toolbar_middleware(middlewares):

REMOTE_SETTINGS_IS_TEST_SERVER = True

# If you have settings you want to overload, put them in a local_settings.py.
try:
from local_settings import * # noqa
except ImportError:
import traceback
import warnings

warnings.warn(
'Could not import local_settings module. {}'.format(traceback.format_exc()),
stacklevel=1,
)
local_settings_path = path('local_settings.py')

if not os.path.exists(local_settings_path):
with open(local_settings_path, 'w') as file:
file.write(
'# If you have settings you want to overload, put them in a local_settings.py.\n'
'from olympia.lib.settings_base import *\n'
)

from local_settings import * # noqa

SITEMAP_DEBUG_AVAILABLE = True

Expand Down

0 comments on commit 31e06f7

Please sign in to comment.