Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcooper committed Sep 23, 2024
1 parent f2345c8 commit 45f29d1
Show file tree
Hide file tree
Showing 20 changed files with 182 additions and 1,707 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ __pycache__/
/server/docker-compose.override.yml
/server/nginx/local-ca/
/server/serve/
/server/tomato/static/tomato/styles.css
/server/tomato/static/vendor/node_modules/

# controller
Expand Down
2 changes: 2 additions & 0 deletions server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ EMAIL_PASSWORD=password
EMAIL_FROM_ADDRESS='Person Name <[email protected]>'
#EMAIL_PORT=587
#EMAIL_USE_TLS=1
# Only used when DEBUG=1, print emails to console instead of sending them
EMAIL_DEBUG_ONLY_PRINT_TO_CONSOLE_ONLY=0

# Required in production for cerbot to function properly
CERTBOT_EMAIL=[email protected]
Expand Down
5 changes: 1 addition & 4 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ FROM "node:${NODE_VERSION}-${DEBIAN_VERSION}-slim" AS node-packages
COPY tomato/ /app/
WORKDIR /app/static/vendor

RUN npm install \
&& npm run build \
&& npm prune --production
RUN npm install


FROM "python:3.12-${DEBIAN_VERSION}" AS final
Expand Down Expand Up @@ -67,7 +65,6 @@ COPY *.py *.sh constants.json /app/
COPY tomato/ /app/tomato/
COPY api/ /app/api/
COPY --from=node-builder /app/static/vendor/node_modules/ /app/tomato/static/vendor/node_modules/
COPY --from=node-builder /app/static/tomato/styles.css /app/tomato/static/tomato/
WORKDIR /app

ENTRYPOINT ["/app/entrypoint.sh"]
Expand Down
1 change: 1 addition & 0 deletions server/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- ./nginx/image/etc/nginx/templates/app.conf.j2:/etc/nginx/templates/app.conf.j2
environment:
USE_LOCAL_CA: "${NGINX_DEBUG_MODE_ONLY_USE_LOCAL_CA:-0}"
LOCAL_CA_ROOT_CERT_VALIDITY: 90 # 90 days instead of 30
DHPARAM_SIZE: 1024 # Faster in dev

db:
Expand Down
3 changes: 3 additions & 0 deletions server/tomato/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
EDIT_ONLY_ASSETS_GROUP_NAME = "Edit ONLY audio assets"
EDIT_ALL_GROUP_NAME = "Edit audio assets, rotators & stop sets"

SUBMIT_TOKEN_MAX_AGE = 20 * 60 # 20 minutes
SUBMIT_URL_PREFIX = "/submit/"

del _data, _file
75 changes: 0 additions & 75 deletions server/tomato/management/commands/runserver.py

This file was deleted.

37 changes: 20 additions & 17 deletions server/tomato/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
PASSWORD_RESET_TIMEOUT = 60 * 60 * 12 # 12 hours

if SUBMIT_VERIFY_EMAIL_ENABLED or EXCEPTIONS_EMAIL_ENABLED or PASSWORD_RESET_EMAIL_ENABLED:
EMAIL_HOST = env("EMAIL_HOST")
EMAIL_HOST_USER = env("EMAIL_USERNAME")
EMAIL_HOST_PASSWORD = env("EMAIL_PASSWORD")
EMAIL_PORT = env.int("EMAIL_PORT", default=587)
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=EMAIL_PORT in (465, 587))
DEFAULT_FROM_EMAIL = SERVER_EMAIL = env("EMAIL_FROM_ADDRESS")
if DEBUG and env.bool("EMAIL_DEBUG_ONLY_PRINT_TO_CONSOLE_ONLY", default=False):
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
else:
EMAIL_HOST = env("EMAIL_HOST")
EMAIL_HOST_USER = env("EMAIL_USERNAME")
EMAIL_HOST_PASSWORD = env("EMAIL_PASSWORD")
EMAIL_PORT = env.int("EMAIL_PORT", default=587)
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=EMAIL_PORT in (465, 587))
DEFAULT_FROM_EMAIL = SERVER_EMAIL = env("EMAIL_FROM_ADDRESS")

if EXCEPTIONS_EMAIL_ENABLED:
EMAIL_ADMIN_ADDRESS = env("EMAIL_ADMIN_ADDRESS_TO_SEND_EXCEPTIONS")
Expand All @@ -49,7 +52,7 @@
ADMIN_NOTICE_TEXT_COLOR = env("ADMIN_NOTICE_TEXT_COLOR", default="#ffffff")
ADMIN_NOTICE_BACKGROUND = env("ADMIN_NOTICE_BACKGROUND", default="#ff0000")

# For development purposes only only
# For development purposes only
HUEY_IMMEDIATE_MODE = DEBUG and env("HUEY_IMMEDIATE_MODE", default=False)

# Compute version
Expand Down Expand Up @@ -81,6 +84,7 @@
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.staticfiles",
# Third-party
"constance",
"django_admin_logs",
Expand All @@ -97,8 +101,6 @@
INSTALLED_APPS.extend([
# Local
"tomato",
# staticfiles comes after tomato, since we override runserver
"django.contrib.staticfiles",
])

AUTH_USER_MODEL = "tomato.User"
Expand All @@ -122,7 +124,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"DIRS": [BASE_DIR / "templates"], # For admin overrides
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down Expand Up @@ -243,6 +245,10 @@
]


DJANGO_ADMIN_LOGS_ENABLED = True
DJANGO_ADMIN_LOGS_DELETABLE = True


def validate_reset_times(values):
if values != "0":
values = (v.strip() for v in values.split("\n") if v.strip())
Expand Down Expand Up @@ -477,7 +483,7 @@ def validate_reset_times(values):

CONSTANCE_CONFIG_FIELDSETS = OrderedDict((
(
"User Interface Options",
"User interface options",
(
"STATION_NAME",
"CLOCK",
Expand All @@ -487,7 +493,7 @@ def validate_reset_times(values):
),
),
(
"Server & Processing Audio Options",
"Server audio processing",
(
"AUDIO_BITRATE",
"EXTRACT_METADATA_FROM_FILE",
Expand All @@ -498,7 +504,7 @@ def validate_reset_times(values):
),
),
(
"Play out options",
"Playout options",
(
"BROADCAST_COMPRESSION",
"WARN_ON_EMPTY_ROTATORS",
Expand All @@ -513,10 +519,7 @@ def validate_reset_times(values):
),
),
))
CONSTANCE_SERVER_ONLY_SETTINGS = set(CONSTANCE_CONFIG_FIELDSETS["Server & Processing Audio Options"])

DJANGO_ADMIN_LOGS_ENABLED = True
DJANGO_ADMIN_LOGS_DELETABLE = True
CONSTANCE_SERVER_ONLY_SETTINGS = set(CONSTANCE_CONFIG_FIELDSETS["Server audio processing"])

SHELL_PLUS_IMPORTS = [
"from constance import config",
Expand Down
1 change: 1 addition & 0 deletions server/tomato/static/tomato/submit/vendor/simple.css
Loading

0 comments on commit 45f29d1

Please sign in to comment.