diff --git a/.gitignore b/.gitignore index 5a65867..84f814e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,6 @@ cover/ # Django stuff: *.log -local_settings.py db.sqlite3 db.sqlite3-journal diff --git a/Dockerfile b/Dockerfile index c41a3fb..1f98816 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # syntax=docker/dockerfile:1 FROM python:3 +ARG OPERATION RUN useradd -d /code xf RUN mkdir -p /code @@ -18,6 +19,10 @@ WORKDIR /code COPY requirements.txt /code/ RUN python -m venv /venv RUN . /venv/bin/activate && pip install -r requirements.txt + # CMD . /venv/bin/activate && uwsgi --ini /conf/uwsgi.ini -CMD . /venv/bin/activate && uvicorn --reload --reload-include *.html --workers 2 --uds /var/run/socks/app.sock app.asgi:application + +CMD if [ "$OPERATION" = "uwsgi" ] ; then . /venv/bin/activate && uwsgi --ini /conf/uwsgi.ini ; else . /venv/bin/activate && exec python manage.py runserver 0.0.0.0:8000; fi + +# CMD . /venv/bin/activate && uvicorn --reload --reload-include *.html --workers 2 --uds /var/run/socks/app.sock app.asgi:application # CMD . /venv/bin/activate && gunicorn -b 0.0.0.0:8000 --reload app.asgi:application -k uvicorn.workers.UvicornWorker \ No newline at end of file diff --git a/app/local_settings.example.py b/app/local_settings.example.py deleted file mode 100644 index 66b0677..0000000 --- a/app/local_settings.example.py +++ /dev/null @@ -1,35 +0,0 @@ -# URLs -DOMAIN = "example.com" -URL = f"https://{DOMAIN}" - -# Access control -ALLOWED_HOSTS = ["127.0.0.1", DOMAIN] - -# CSRF -CSRF_TRUSTED_ORIGINS = [URL] - -# Stripe -STRIPE_TEST = True -STRIPE_API_KEY_TEST = "" -STRIPE_PUBLIC_API_KEY_TEST = "" - -STRIPE_API_KEY_PROD = "" -STRIPE_PUBLIC_API_KEY_PROD = "" - -STRIPE_ENDPOINT_SECRET = "" -STATIC_ROOT = "" -SECRET_KEY = "a" - -STRIPE_ADMIN_COUPON = "" - -DEBUG = True -PROFILER = False - -if DEBUG: - import socket # only if you haven't already imported this - - hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + [ - "127.0.0.1", - "10.0.2.2", - ] diff --git a/app/local_settings.py b/app/local_settings.py new file mode 100644 index 0000000..d1ccb1d --- /dev/null +++ b/app/local_settings.py @@ -0,0 +1,42 @@ +from os import getenv + +trues = ("t", "true", "yes", "y", "1") + +# URLs +DOMAIN = getenv("DOMAIN", "example.com") +URL = getenv("URL", f"https://{DOMAIN}") + +# Access control +ALLOWED_HOSTS = getenv("ALLOWED_HOSTS", f"127.0.0.1,{DOMAIN}").split(",") + +# CSRF +CSRF_TRUSTED_ORIGINS = getenv("CSRF_TRUSTED_ORIGINS", URL).split(",") + +# Stripe +STRIPE_ENABLED = getenv("STRIPE_ENABLED", "false").lower() in trues +STRIPE_TEST = getenv("STRIPE_TEST", "true") in trues +STRIPE_API_KEY_TEST = getenv("STRIPE_API_KEY_TEST", "") +STRIPE_PUBLIC_API_KEY_TEST = getenv("STRIPE_PUBLIC_API_KEY_TEST", "") + +STRIPE_API_KEY_PROD = getenv("STRIPE_API_KEY_PROD", "") +STRIPE_PUBLIC_API_KEY_PROD = getenv("STRIPE_PUBLIC_API_KEY_PROD", "") + +STRIPE_ENDPOINT_SECRET = getenv("STRIPE_ENDPOINT_SECRET", "") +STATIC_ROOT = getenv("STATIC_ROOT", "") +SECRET_KEY = getenv("SECRET_KEY", "") + +STRIPE_ADMIN_COUPON = getenv("STRIPE_ADMIN_COUPON", "") + +DEBUG = getenv("DEBUG", "false") in trues +PROFILER = getenv("PROFILER", "false") in trues + +if DEBUG: + import socket # only if you haven't already imported this + + hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) + INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + [ + "127.0.0.1", + "10.0.2.2", + ] + +SETTINGS_EXPORT = ["STRIPE_ENABLED"] diff --git a/core/lib/products.py b/core/lib/products.py index 9e9e191..f087f8c 100644 --- a/core/lib/products.py +++ b/core/lib/products.py @@ -1,14 +1,12 @@ -from asgiref.sync import sync_to_async - from core.models import Plan -async def assemble_plan_map(product_id_filter=None): +def assemble_plan_map(product_id_filter=None): """ Get all the plans from the database and create an object Stripe wants. """ line_items = [] - for plan in await sync_to_async(list)(Plan.objects.all()): + for plan in Plan.objects.all(): if product_id_filter: if plan.product_id != product_id_filter: continue diff --git a/core/templates/wm/modal.html b/core/templates/wm/modal.html index c5973af..b8e5614 100644 --- a/core/templates/wm/modal.html +++ b/core/templates/wm/modal.html @@ -12,8 +12,9 @@ \ No newline at end of file diff --git a/core/templates/wm/page.html b/core/templates/wm/page.html new file mode 100644 index 0000000..93ea8c1 --- /dev/null +++ b/core/templates/wm/page.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + + +{% block content %} + {% include window_content %} +{% endblock %} diff --git a/core/templates/wm/panel.html b/core/templates/wm/panel.html index e57d573..b180b38 100644 --- a/core/templates/wm/panel.html +++ b/core/templates/wm/panel.html @@ -3,9 +3,7 @@

{% block close_button %} - + {% include 'partials/close-window.html' %} {% endblock %} {% block heading %} {% endblock %} diff --git a/core/templates/wm/widget.html b/core/templates/wm/widget.html index dafc773..9ef8154 100644 --- a/core/templates/wm/widget.html +++ b/core/templates/wm/widget.html @@ -1,24 +1,24 @@

-
+