Skip to content

Commit

Permalink
feat: enable livesync only in development mode
Browse files Browse the repository at this point in the history
  • Loading branch information
victoriacesar authored Sep 13, 2024
1 parent 162fbce commit 6b056ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ENV=dev
DEBUG=True
SECRET_KEY=')c*%*n=#oz9*hl@8py6_-pl^s7n%ae=g05+y-z3jx7sc+ua69q'
DATABASE_URL=postgresql://queremossaber:queremossaber@localhost/queremossaber
Expand Down
18 changes: 15 additions & 3 deletions web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CSRF_COOKIE_SECURE=(bool, False),
CSRF_COOKIE_DOMAIN=(str, None),
CSRF_TRUSTED_ORIGINS=(list, ["queremossaber.org.br"]),
ENV=(str, "dev"),
)
env.read_env(env.str("ENV_PATH"))

Expand All @@ -43,6 +44,8 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")

ENV = env("ENV")

ALLOWED_HOSTS = (
[
"queremossaber.org.br",
Expand All @@ -63,6 +66,10 @@

# Application definition

extra_apps = []
if ENV == "dev":
extra_apps += ["livesync"]

INSTALLED_APPS = [
"web.foi_requests",
"web.whoami",
Expand All @@ -72,11 +79,16 @@
"django.contrib.sessions",
"django.contrib.messages",
"raven.contrib.django.raven_compat",
"livesync",
"django.contrib.staticfiles",
"widget_tweaks",
"debug_toolbar",
]
] + extra_apps

extra_middleware = []
if ENV == "dev":
extra_middleware += [
"livesync.core.middleware.DjangoLiveSyncMiddleware",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
Expand All @@ -89,7 +101,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
"livesync.core.middleware.DjangoLiveSyncMiddleware",
]
] + extra_middleware

ROOT_URLCONF = "web.urls"

Expand Down

0 comments on commit 6b056ec

Please sign in to comment.