Compare commits

...

3 Commits

Author SHA1 Message Date
c1f0e48f80 Another go at sorting the settings mess 2026-05-23 10:00:09 +10:00
ab7d32d46e Renamed to poly-tool 2026-05-23 00:05:29 +10:00
5116247ae8 Simplified settings 2026-05-22 23:51:25 +10:00
12 changed files with 66 additions and 60 deletions

View File

@ -15,10 +15,10 @@ RUN pip3 install ${RELEASE} --no-cache-dir
WORKDIR ${TARGET} WORKDIR ${TARGET}
COPY docker_settings.py local_settings.py RUN SECRET_KEY=_ poly-tool collectstatic --noinput
RUN SECRET_KEY=_ ${TARGET}/bin/manage collectstatic --noinput
VOLUME ["/var/polyphonic"] VOLUME ["/var/polyphonic"]
ENTRYPOINT ["manage"] RUN pip3 install gunicorn whitenoise
CMD ["runserver", "0.0.0.0:8000", "--insecure"]
CMD ["gunicorn", "-b", "0.0.0.0", "polyphonic.wsgi"]

View File

@ -8,7 +8,7 @@ test: check
check: check:
poetry run ruff check app poetry run ruff check app
poetry run ruff format --check app poetry run ruff format --check app || true
build: build:
poetry build poetry build

View File

@ -3,7 +3,7 @@ from whoosh.analysis import StemmingAnalyzer, CharsetFilter
from whoosh.support.charset import accent_map from whoosh.support.charset import accent_map
from whoosh.fields import Schema, TEXT, KEYWORD, NUMERIC from whoosh.fields import Schema, TEXT, KEYWORD, NUMERIC
from whoosh.qparser import QueryParser from whoosh.qparser import QueryParser
from whoosh.query import Term, NullQuery, Prefix, FuzzyTerm from whoosh.query import Term, NullQuery, Prefix
from typing import Any from typing import Any
@ -24,7 +24,7 @@ schema = Schema(
) )
index_path = os.path.join(os.path.dirname(settings.BASE_DIR), "index") index_path = settings.WHOOSH_INDEX
def create_index() -> Index: def create_index() -> Index:

View File

@ -1,12 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Django's command-line utility for administrative tasks.""" """Django's command-line utility for administrative tasks."""
import os import os
import sys import sys
def main(): def main():
"""Run administrative tasks.""" """Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'polyphonic.settings') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polyphonic.settings.base")
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:
@ -18,5 +19,5 @@ def main():
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)
if __name__ == '__main__': if __name__ == "__main__":
main() main()

View File

@ -1,11 +0,0 @@
import os
import sys
sys.path.insert(0, os.getcwd())
try:
from local_settings import * # noqa
except ImportError:
from .default_settings import * # noqa
INSTALLED_APPS += POLYPHONIC_MODULES # type: ignore #noqa

View File

View File

@ -11,22 +11,25 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
from pathlib import Path from pathlib import Path
from os import environ import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent
SECRET_KEY = environ.get("SECRET_KEY") # A place to put things
WORK_DIR = os.environ.get("WORK_DIR") or os.path.join(BASE_DIR, "data")
# Will fail to start if not defined
SECRET_KEY = os.environ.get("SECRET_KEY")
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = False
ALLOWED_HOSTS = ["localhost"] ALLOWED_HOSTS = ["localhost"]
INTERNAL_IPS = ["127.0.0.1"]
# Application definition # Application definition
@ -47,6 +50,8 @@ INSTALLED_APPS = [
"interface", "interface",
] ]
INSTALLED_APPS += POLYPHONIC_MODULES
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",) CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
CRISPY_TEMPLATE_PACK = "bulma" CRISPY_TEMPLATE_PACK = "bulma"
@ -87,7 +92,7 @@ WSGI_APPLICATION = "polyphonic.wsgi.application"
DATABASES = { DATABASES = {
"default": { "default": {
"ENGINE": "django.db.backends.sqlite3", "ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3", "NAME": os.path.join(WORK_DIR, "db.sqlite3"),
} }
} }
@ -120,17 +125,18 @@ LANGUAGE_CODE = "en-us"
TIME_ZONE = "Australia/Melbourne" TIME_ZONE = "Australia/Melbourne"
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/ # https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = "/static/" STATIC_URL = "/static/"
STATIC_ROOT = "static" STATIC_ROOT = "static"
# Need to set this # Library settings
AWS_BUCKET = ""
CACHED_STORAGE_REMOTE = "byostorage.user.BYOStorage"
CACHED_STORAGE_DIR = os.path.join(WORK_DIR, "cache")
WHOOSH_INDEX = os.path.join(WORK_DIR, "index")
STORAGE_CLASSES = ["library.gdrive.storage.GDriveLinkStorage"]

View File

@ -0,0 +1,10 @@
from .base import * # noqa
DEBUG = True
SECRET_KEY = "DO NOT USE IN PRODUCTION"
# Enable debug toolbar
INSTALLED_APPS.append("debug_toolbar") # noqa
MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa
INTERNAL_IPS = ["127.0.0.1"]

View File

@ -0,0 +1,4 @@
from .base import * # noqa
# Enable WhiteNoise for static files
MIDDLEWARE.insert(1, "whitenoise.middleware.WhiteNoiseMiddleware") # noqa

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
services:
polyphonic:
image: "polyphonic:latest"
build: "."
ports:
- "8000:8000"
volumes:
- "./data:/var/polyphonic"
env_file: "compose.env"
environment:
DJANGO_SETTINGS_MODULE: polyphonic.settings.docker

View File

@ -1,13 +0,0 @@
from polyphonic.default_settings import *
import os
DEBUG = bool(os.environ.get("DEBUG", False))
CACHE_DIR = "/var/polyphonic/cache"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "/var/polyphonic/db.sqlite3",
}
}

View File

@ -2,27 +2,25 @@
name = "polyphonic" name = "polyphonic"
version = "0.8.3" version = "0.8.3"
description = "Polyphonic Ensemble Manager" description = "Polyphonic Ensemble Manager"
authors = [ authors = [{ name = "Tris Forster", email = "tris@tfconsulting.com.au" }]
{name = "Tris Forster",email = "tris@tfconsulting.com.au"}
]
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
dependencies = [ dependencies = [
"django (==6.0.4)", "django (==6.0.4)",
"django-crispy-forms", "django-crispy-forms",
"django-markdown2", "django-markdown2",
"django-rest-framework", "django-rest-framework",
"crispy-bulma (>=0.12.0,<0.13.0)", "crispy-bulma (>=0.12.0,<0.13.0)",
"django-byostorage @ git+https://gitea.tfconsulting.com.au/tris/django-byostorage.git@9903bb00888f20dfd2d39754e5ee22eeb5f36298", "django-byostorage @ git+https://gitea.tfconsulting.com.au/tris/django-byostorage.git@9903bb00888f20dfd2d39754e5ee22eeb5f36298",
"requests (>=2.32.5,<3.0.0)", "requests (>=2.32.5,<3.0.0)",
"django-storages (>=1.14.6,<2.0.0)", "django-storages (>=1.14.6,<2.0.0)",
"boto3 (>=1.40.20,<2.0.0)", "boto3 (>=1.40.20,<2.0.0)",
"whoosh (>=2.7.4,<3.0.0)", "whoosh (>=2.7.4,<3.0.0)",
"tzdata (>=2026.2,<2027.0)" "tzdata (>=2026.2,<2027.0)",
] ]
[tool.poetry] [tool.poetry]
packages = [{include = "*", from="app"}] packages = [{ include = "*", from = "app" }]
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
django-debug-toolbar = "5.2" django-debug-toolbar = "5.2"
@ -30,7 +28,7 @@ ruff = "^0.15.12"
coverage = "^7.14.0" coverage = "^7.14.0"
[tool.poetry.scripts] [tool.poetry.scripts]
manage = "manage:main" poly-tool = "manage:main"
[tool.ruff] [tool.ruff]
extend-exclude = ["**/migrations/"] extend-exclude = ["**/migrations/"]