diff --git a/.gitea/workflows/build_test.yaml b/.gitea/workflows/build_test.yaml index b959ef6..f71de77 100644 --- a/.gitea/workflows/build_test.yaml +++ b/.gitea/workflows/build_test.yaml @@ -4,6 +4,7 @@ on: push: branches: - pre-prod + - main pull_request: jobs: diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 6f925f9..7939c2d 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -31,5 +31,8 @@ jobs: echo "Building containers..." make prod + echo "Running Django deploy check" + docker compose run --rm web python manage.py check --deploy + echo "Deployment complete." EOF \ No newline at end of file diff --git a/.gitignore b/.gitignore index 738f029..7426210 100644 --- a/.gitignore +++ b/.gitignore @@ -175,3 +175,7 @@ cython_debug/ # PyPI configuration file .pypirc +# gunicon webserver +gunicorn.ctl + + diff --git a/Makefile b/Makefile index 4e2289a..c61f5ba 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ prod: dev: docker compose down - docker compose -f ./compose.yaml -f ./compose.dev.yaml up --build + docker compose -f ./compose.yaml -f ./compose.dev.yaml up --build -d + docker exec -it quatsh-website-web-1 sh test: docker compose --env-file .env.template -f ./compose.yaml -f ./compose.test.yaml up --build --abort-on-container-exit --exit-code-from web diff --git a/README.md b/README.md index 3e91f22..abd0593 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Requirements: ### Install make -Running this requires the use of "make" and docker.\ +Running this requires the use of "make" and docker. "make" tends to come pre-installed on linux but not on Windows, to install it on Windows I recommend using Chocolatey as follows: \ ``` diff --git a/compose.yaml b/compose.yaml index 36e320f..4c14151 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: db: image: postgres:18 environment: - POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_DB: ${POSTGRES_DBNAME} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: diff --git a/src/polls/__init__.py b/src/polls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/polls/admin.py b/src/polls/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/src/polls/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/src/polls/apps.py b/src/polls/apps.py new file mode 100644 index 0000000..d0f109e --- /dev/null +++ b/src/polls/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PollsConfig(AppConfig): + name = 'polls' diff --git a/src/polls/migrations/__init__.py b/src/polls/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/polls/models.py b/src/polls/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/src/polls/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/src/polls/tests.py b/src/polls/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/src/polls/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/src/polls/urls.py b/src/polls/urls.py new file mode 100644 index 0000000..5119061 --- /dev/null +++ b/src/polls/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.index, name="index"), +] diff --git a/src/polls/views.py b/src/polls/views.py new file mode 100644 index 0000000..933bf0d --- /dev/null +++ b/src/polls/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render +from django.http import HttpResponse + + +def index(request): + return HttpResponse("Hello, world. You're at the polls index.") + + +# Create your views here. diff --git a/src/website/settings.py b/src/website/settings.py index 7a4d735..0264fb5 100644 --- a/src/website/settings.py +++ b/src/website/settings.py @@ -21,10 +21,10 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-c$q7wdq+u@ow74wp!&zzkxdylkueu)(+34e%!e0du&bjwoqz9z" +SECRET_KEY = os.environ["DJANGO_SECRET_KEY"] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = bool(os.getenv("DEBUG")) +DEBUG = bool(os.getenv("DEBUG", False)) ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",") @@ -77,7 +77,7 @@ WSGI_APPLICATION = "website.wsgi.application" DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "DBNAME": os.getenv("POSTGRES_DBNAME"), + "NAME": os.getenv("POSTGRES_DBNAME"), "USER": os.getenv("POSTGRES_USER"), "PASSWORD": os.getenv("POSTGRES_PASSWORD"), "HOST": os.getenv("POSTGRES_HOST"), @@ -110,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = "en-us" -TIME_ZONE = "UTC" +TIME_ZONE = "Europe/Amsterdam" USE_I18N = True diff --git a/src/website/urls.py b/src/website/urls.py index ac9ab57..37f07e2 100644 --- a/src/website/urls.py +++ b/src/website/urls.py @@ -14,9 +14,11 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ - path('admin/', admin.site.urls), + path("polls/", include("polls.urls")), + path("admin/", admin.site.urls), ]