Commit c370d741 authored by Joachim Kołodziejski's avatar Joachim Kołodziejski
Browse files

Merge branch 'asgi' into 'main'

Terminals, landing page, SMTP settings in admin panel, other smaller changes

See merge request !1
parents 9947d76b 3a916d3b
Loading
Loading
Loading
Loading
+1 −1
Changes for Procfile: 1 added line, 1 removed line.
Original line number Diff line number Diff line
web: uv run manage.py runserver
web: uv run uvicorn wybory.asgi:application --reload --host 0.0.0.0
worker: uv run manage.py rqworker default email email_batch reports --job-class django_tasks_rq.Job
+3 −3
Changes for README.md: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ Voting system, initially developed for [XIV LO in Warsaw](https://staszic.waw.pl
    WorkingDirectory=/var/www/wybory
    ExecStartPre=/var/www/wybory/.venv/bin/python manage.py migrate --no-input
    ExecStartPre=/var/www/wybory/.venv/bin/python manage.py collectstatic --no-input
    ExecStart=/var/www/wybory/.venv/bin/gunicorn -c gunicorn.conf.py wybory.wsgi
    ExecStart=/var/www/wybory/.venv/bin/gunicorn -c gunicorn.conf.py wybory.asgi
    StandardOutput=file:/var/log/wybory/stdout.log
    StandardError=file:/var/log/wybory/stderr.log
    Restart=always
@@ -86,8 +86,8 @@ Voting system, initially developed for [XIV LO in Warsaw](https://staszic.waw.pl
    You can adjust gunicorn configuration with command line arguments (see `sudo -u wybory uv run gunicorn --help`),
    or by providing a different config file than `/var/www/wybory/gunicorn.conf.py`.

    It it advised to adjust the number of workers (`--workers <number-of-workers>` or `workers` variable in the config file).

- start and enable the services (for systemd: `systemctl start wybory.service && systemctl enable wybory.service && systemctl start wybory-worker.service && systemctl enable wybory-worker.service`)
- create a superuser `sudo -u wybory uv run python manage.py createsuperuser`
- serve the traffic through a reverse proxy

To upgrade, pull the latest changes, install new dependencies (`sudo -u wybory uv sync --locked`), adjust the config if the new version requires it and restart the service.
+2 −2
Changes for elections/models.py: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ class Election(models.Model):

        return super().save(*args, **kwargs)

    def cast_vote(self, voter, choice):
    def cast_vote(self, voter, choice, terminal=None):
        if choice == "invalid":
            self.invalid_votes += 1
            self.save()
@@ -111,7 +111,7 @@ class Election(models.Model):

        from vote.models import Participation

        participation = Participation(voter=voter, election=self)
        participation = Participation(voter=voter, election=self, assigned_by=(terminal.assigned_by if terminal else None), is_remote=(False if terminal is not None else True))
        participation.save()

    class Meta:
+1 −1
Changes for entrypoint.sh: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ if [ "$1" = "web" ]; then
        ./manage.py createsuperuser --noinput
        set -e
    fi
    gunicorn -c gunicorn.conf.py wybory.wsgi
    gunicorn -c gunicorn.conf.py wybory.asgi
elif [ "$1" = "worker" ]; then
    ./manage.py rqworker default email email_batch --job-class django_tasks_rq.Job
else
+2 −1
Changes for gunicorn.conf.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
bind = "0.0.0.0:8000"

workers = 2
workers = 4
worker_class = "uvicorn_worker.UvicornWorker"

loglevel = "info"
errorlog = "-"
Loading