Skip to content

Commit

Permalink
Improve and verify poll pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsargent committed Jul 24, 2024
1 parent 1b0ae5f commit e0a7572
Show file tree
Hide file tree
Showing 15 changed files with 796 additions and 1,614 deletions.
50 changes: 26 additions & 24 deletions approval_polls/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,41 @@
SECRET_KEY = env("SECRET_KEY")

db_path = "/data/prod.sqlite3"

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
APP_NAME = env("FLY_APP_NAME", str, "")
ALLOWED_HOSTS = [f"{APP_NAME}.fly.dev", "vote.electionscience.org"] # ← Updated!

if DEBUG:
db_path = os.path.join(BASE_DIR, "db.sqlite3")
CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"]
CSRF_ALLOWED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"]
CORS_ORIGINS_WHITELIST = ["http://localhost:8000", "http://127.0.0.1:8000"]
ALLOWED_HOSTS.extend(["localhost", "0.0.0.0", "127.0.0.1"])

Check warning on line 39 in approval_polls/settings.py

View check run for this annotation

Trunk.io / Trunk Check

bandit(B104)

[new] Possible binding to all interfaces.

if not DEBUG:
COMPRESS_OFFLINE = True
LIBSASS_OUTPUT_STYLE = "compressed"
sentry_sdk.init(
dsn="https://78856604267db99554868743d5eb61e5@o4506681396625408.ingest.sentry.io/4506681396756480",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
CSRF_TRUSTED_ORIGINS = ["https://vote.electionscience.org"]
CSRF_ALLOWED_ORIGINS = ["https://vote.electionscience.org"]
CORS_ORIGINS_WHITELIST = ["https://vote.electionscience.org"]


if "test" in sys.argv:
COMPRESS_OFFLINE = False
COMPRESS_ENABLED = False


DATABASES = {
"default": {
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
Expand All @@ -45,16 +68,6 @@
}
}

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
APP_NAME = env("FLY_APP_NAME", str, "")
ALLOWED_HOSTS = [f"{APP_NAME}.fly.dev", "vote.electionscience.org"] # ← Updated!
if DEBUG:
ALLOWED_HOSTS.extend(["localhost", "0.0.0.0", "127.0.0.1"])

CSRF_TRUSTED_ORIGINS = ["https://vote.electionscience.org"]
CSRF_ALLOWED_ORIGINS = ["https://vote.electionscience.org"]
CORS_ORIGINS_WHITELIST = ["https://vote.electionscience.org"]

# The following settings are required for the activation emails in the
# registration module to work.
Expand Down Expand Up @@ -136,7 +149,7 @@

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
"django.template.loaders.filesystem.Loader",
"django.template.loaders.filesystem.Loader"
"django.template.loaders.app_directories.Loader",
)

Expand All @@ -149,6 +162,7 @@
"django_ajax.middleware.AJAXMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
)

ROOT_URLCONF = "approval_polls.urls"
Expand Down Expand Up @@ -274,15 +288,3 @@
# ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5 # or any reasonable number
ACCOUNT_RATE_LIMITS = False
ACCOUNT_FORMS = {"signup": "approval_polls.forms.CustomSignupForm"}


sentry_sdk.init(
dsn="https://78856604267db99554868743d5eb61e5@o4506681396625408.ingest.sentry.io/4506681396756480",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
Loading

0 comments on commit e0a7572

Please sign in to comment.