Skip to content

Commit

Permalink
refactor: remove obsolete .django_secret
Browse files Browse the repository at this point in the history
The removed code is unreachable due to SECRET_KEY being always defined
in settings.py
  • Loading branch information
voneiden committed Nov 4, 2024
1 parent f7764bc commit 64d02cb
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions linkedevents/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,37 +586,6 @@ def dummy_haystack_connection_for_lang(language_code):
# shown in the browsable API
INSTANCE_NAME = env("INSTANCE_NAME")

# We generate a persistent SECRET_KEY if it is not defined. Note that
# setting SECRET_KEY will override the persisted key
if "SECRET_KEY" not in locals():
secret_file = os.path.join(BASE_DIR, ".django_secret")
try:
SECRET_KEY = open(secret_file).read().strip()
except IOError:
import random

system_random = random.SystemRandom()
try:
SECRET_KEY = "".join(
[
system_random.choice(
"abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
)
for i in range(64)
]
)
secret = open(secret_file, "w")
import os

os.chmod(secret_file, 0o0600)
secret.write(SECRET_KEY)
secret.close()
except IOError:
raise Exception(
"Please create a %s file with random characters to generate your secret key!" # noqa: E501
% secret_file
)

# Email configuration
EMAIL_HOST = env("EMAIL_HOST")
EMAIL_PORT = env("EMAIL_PORT")
Expand Down

0 comments on commit 64d02cb

Please sign in to comment.