Compare commits

...

10 Commits

Author SHA1 Message Date
e0675c8684 Merge pull request 'Update .env.template' (#18) from woutervermeer-patch-1 into main
Some checks failed
Gitea build & Test. / tests (push) Failing after 5s
Deploy to production / deploy (push) Failing after 31s
Gitea build & Test. / tests (pull_request) Failing after 6s
Gitea Test. / tests (pull_request) Successful in 6s
Reviewed-on: #18
2026-03-26 09:52:42 +00:00
4b18769137 Update .env.template
Some checks failed
Gitea build & Test. / tests (pull_request) Failing after 7s
Gitea Test. / tests (pull_request) Successful in 6s
2026-03-26 09:52:33 +00:00
90b7bb0dee Merge pull request 'pre-prod' (#17) from pre-prod into main
Some checks failed
Gitea build & Test. / tests (push) Failing after 6s
Deploy to production / deploy (push) Failing after 1m19s
Reviewed-on: #17
2026-03-26 08:17:36 +00:00
8cfe5c6f9b Add .gitea/workflows/test.yaml
Some checks failed
Gitea Test. / tests (push) Successful in 6s
Gitea build & Test. / tests (pull_request) Failing after 6s
Gitea Test. / tests (pull_request) Successful in 6s
2026-03-26 08:15:11 +00:00
9397c2d4f2 Update .gitea/workflows/build_test.yaml
Some checks failed
Gitea build & Test. / tests (pull_request) Failing after 6s
2026-03-26 08:14:25 +00:00
313702f9fe Update Makefile
Some checks failed
Gitea build & Test. / tests (push) Failing after 13s
Gitea build & Test. / tests (pull_request) Failing after 7s
2026-03-26 08:09:28 +00:00
WGAVermeer
49199b7184 slightly updated README.md
Some checks failed
Gitea build & Test. / tests (push) Failing after 7s
2026-03-26 08:27:10 +01:00
WGAVermeer
c17e3e85f2 added auto-reload when developing.
Some checks failed
Gitea build & Test. / tests (push) Failing after 21s
2026-03-25 17:11:14 +01:00
WGAVermeer
be54afa093 fix makefile pt2
Some checks failed
Gitea build & Test. / tests (push) Failing after 27s
2026-03-25 15:47:29 +01:00
WGAVermeer
fd5414bd5a fix type in makefile
Some checks failed
Gitea build & Test. / tests (push) Failing after 2s
2026-03-25 15:46:46 +01:00
13 changed files with 130 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
services: services:
web: web:
command: gunicorn -b 0.0.0.0:8000 website.wsgi:application command: gunicorn --capture-output --enable-stdio-inheritance -b 0.0.0.0:8000 website.wsgi:application
volumes: volumes:
- ./src:/src - ./src:/src
env_file: env_file:

View File

@@ -1,8 +1,11 @@
#NGINX
NGINX_HOSTNAME=localhost
# Django # Django
DJANGO_SETTINGS_MODULE=website.settings DJANGO_SETTINGS_MODULE=website.settings
DJANGO_SECRET_KEY=CWHZCAZBNV57tDkwGHJwTUu3PCSnGG45 DJANGO_SECRET_KEY=CWHZCAZBNV57tDkwGHJwTUu3PCSnGG45
DEBUG=TRUE DEBUG=TRUE
ALLOWED_HOSTS=localhost #ALLOWED_HOSTS=localhost
# Database (PostgreSQL) # Database (PostgreSQL)
POSTGRES_USER=test_user POSTGRES_USER=test_user

View File

@@ -3,7 +3,6 @@ run-name: ${{ gitea.actor }}
on: on:
push: push:
branches: branches:
- pre-prod
- main - main
pull_request: pull_request:

View File

@@ -0,0 +1,17 @@
name: Gitea Test.
run-name: ${{ gitea.actor }}
on:
push:
branches:
- pre-prod
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: test
run: make test

View File

@@ -1,6 +1,6 @@
prod: prod:
docker compose down docker compose down
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.prod.yaml up -d --build docker compose --env-file .env -f ./compose.yaml -f ./.docker-compose-files/compose.prod.yaml up -d --build
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
docker exec quatsh-website-web-1 python manage.py check --deploy docker exec quatsh-website-web-1 python manage.py check --deploy
docker exec quatsh-website-web-1 python manage.py migrate docker exec quatsh-website-web-1 python manage.py migrate
@@ -11,6 +11,16 @@ dev:
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
docker exec -it quatsh-website-web-1 sh docker exec -it quatsh-website-web-1 sh
test: dev_restart:
docker compose --env-file .env.template -f ./compose.yaml -f ./.docker-compose_files up --build --abort-on-container-exit --exit-code-from web docker compose down
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up -d
docker exec -it quatsh-website-web-1 sh
dev_restart_with_logs:
docker compose down
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up
test:
docker compose --env-file .env.template -f ./compose.yaml -f ./.docker-compose-files/compose.test.yaml up --build --abort-on-container-exit --exit-code-from web

View File

@@ -1,44 +1,65 @@
# Quatsh-Website # Quatsh-Website
## Requirements: ## Requirements
### Install make ### 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: \ "make" tends to come pre-installed on linux but not on Windows, to install it on Windows I recommend using Chocolatey as follows: \
``` ```
choco install make choco install make
``` ```
### Install docker ### Install docker
https://docs.docker.com/get-started/get-docker/
<https://docs.docker.com/get-started/get-docker/>
## Running for the first time ## Running for the first time
### Env ### Env
Before running the container environment has to be setup first, so first run: Before running the container environment has to be setup first, so first run:
``` ```
cp .env.template .env cp .env.template .env
``` ```
Then make any nessecary adjustments to the .env file.
### Running the website: Then make any changes to the .env file.
### Running the website
To run the website 3 options have been provided To run the website 3 options have been provided
#### Development:
#### Development
For development purposes only as the src folder has been mounted in the container to allow for the making of changes without rebuilding the entire image. For development purposes only as the src folder has been mounted in the container to allow for the making of changes without rebuilding the entire image.
``` Properly utilising this also requires the DEBUG environment variable to be set to TRUE.
```shell
make dev make dev
``` ```
#### Testing #### Testing
Runs the testing environment and exits. Runs the testing environment and exits.
```
```shell
make test make test
``` ```
#### Production #### Production
Using `make prod` is identical but preferred here. Using `make prod` is identical but preferred here.
```
```shell
make prod make prod
# or ```
Or
```shell
make make
``` ```

View File

@@ -1,3 +1,5 @@
Django==6.0.3 Django==6.0.3
gunicorn==25.1.0 gunicorn==25.1.0
psycopg [binary] ==3.3.3 psycopg [binary] ==3.3.3
django-browser-reload
django-watchfiles

View File

@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>My test page</title>
</head>
<body>
<h1>Hey This is a test of watchfiles + browser reload!</h1>
{{ question }}
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>My test page</title>
</head>
<body>
{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
</body>
</html>

View File

@@ -3,5 +3,12 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
# ex: /polls/
path("", views.index, name="index"), path("", views.index, name="index"),
# ex: /polls/5/
path("<int:question_id>/", views.detail, name="detail"),
# ex: /polls/5/results/
path("<int:question_id>/results/", views.results, name="results"),
# ex: /polls/5/vote/
path("<int:question_id>/vote/", views.vote, name="vote"),
] ]

View File

@@ -1,9 +1,24 @@
from django.shortcuts import render from django.http import HttpResponse, Http404
from django.http import HttpResponse from django.shortcuts import get_object_or_404, render
from .models import Question
def index(request): def index(request):
return HttpResponse("Hello, world. You're at the polls index.") latest_question_list = Question.objects.order_by("-pub_date")[:5]
context = {"latest_question_list": latest_question_list}
return render(request, "polls/index.html", context)
# Create your views here. def detail(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, "polls/detail.html", {"question": question})
def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)
def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

View File

@@ -40,6 +40,8 @@ INSTALLED_APPS = [
"django.contrib.sessions", "django.contrib.sessions",
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
"django_browser_reload",
"django_watchfiles",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@@ -50,6 +52,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_browser_reload.middleware.BrowserReloadMiddleware",
] ]
ROOT_URLCONF = "website.urls" ROOT_URLCONF = "website.urls"

View File

@@ -19,6 +19,7 @@ from django.contrib import admin
from django.urls import path, include from django.urls import path, include
urlpatterns = [ urlpatterns = [
path("__reload__/", include("django_browser_reload.urls")),
path("polls/", include("polls.urls")), path("polls/", include("polls.urls")),
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
] ]