diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..a4d0506 --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,29 @@ +name: Build and push Docker image + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: code.edgarpierre.fr + username: ${{ vars.DOCKER_PUSH_USERNAME }} + password: ${{ secrets.DOCKER_PUSH_PASSWORD }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: | + code.edgarpierre.fr/${{ github.repository }}:${{ github.ref_name }} + code.edgarpierre.fr/${{ github.repository }}:latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b84af83..d6f30de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,10 @@ repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: no-commit-to-branch + args: ["--branch", "main"] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0d096fe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "program": "${workspaceFolder}\\nummi\\manage.py", + "args": [ + "runserver" + ], + "env": { + "NUMMI_CONFIG": "${workspaceFolder}\\env\\config.toml" + }, + "django": true + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5af2d67 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ghcr.io/astral-sh/uv:debian-slim + +ADD . /app +WORKDIR /app + +RUN useradd -m -r nummi && \ + chown -R nummi /app + +USER nummi + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +ENV NUMMI_CONFIG=/nummi/config.toml + +RUN uv sync --locked + +CMD ["/app/entrypoint.sh"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..6a35721 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,23 @@ +services: + nummi: + image: code.edgarpierre.fr/edpibu/nummi + container_name: nummi + restart: unless-stopped + ports: + - 33001:8000 + volumes: + - /docker/nummi/config:/nummi + - /docker/nummi/static:/app/static + - /docker/nummi/media:/app/media + depends_on: + - postgres + + postgres: + image: postgres:17-alpine + container_name: nummi_postgres + restart: unless-stopped + environment: + POSTGRES_USER: nummi + POSTGRES_PASSWORD: + volumes: + - /docker/nummi/postgres:/var/lib/postgresql/data \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..370a6fe --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +cd /app/nummi +uv run manage.py collectstatic --noinput +uv run manage.py migrate --noinput +uv run gunicorn --bind :8000 --workers 2 nummi.wsgi:application \ No newline at end of file diff --git a/nummi/account/forms.py b/nummi/account/forms.py index cde1416..8dc869a 100644 --- a/nummi/account/forms.py +++ b/nummi/account/forms.py @@ -1,3 +1,4 @@ +from django.forms.widgets import Select from main.forms import IconInput, NummiForm from .models import Account @@ -15,3 +16,7 @@ class AccountForm(NummiForm): widgets = { "icon": IconInput(), } + + +class AccountSelect(Select): + template_name = "account/forms/widgets/account.html" diff --git a/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo b/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo index d0a97cf..52b402c 100644 Binary files a/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo and b/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo differ diff --git a/nummi/account/locale/fr_FR/LC_MESSAGES/django.po b/nummi/account/locale/fr_FR/LC_MESSAGES/django.po index 14f7e1a..30ea931 100644 --- a/nummi/account/locale/fr_FR/LC_MESSAGES/django.po +++ b/nummi/account/locale/fr_FR/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-04 16:18+0100\n" +"POT-Creation-Date: 2025-01-04 18:51+0100\n" "PO-Revision-Date: 2023-04-22 15:17+0200\n" "Last-Translator: Edgar P. Burkhart \n" "Language-Team: \n" @@ -17,46 +17,59 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 3.2.2\n" -#: .\account\models.py:11 .\account\models.py:37 .\account\models.py:45 +#: .\account\models.py:12 .\account\models.py:45 .\account\models.py:53 +#: .\account\templates\account\account_list.html:9 msgid "Account" msgstr "Compte" -#: .\account\models.py:11 +#: .\account\models.py:12 msgid "Name" msgstr "Nom" -#: .\account\models.py:15 +#: .\account\models.py:16 msgid "Icon" msgstr "Icône" -#: .\account\models.py:17 +#: .\account\models.py:18 msgid "Default" msgstr "Défaut" -#: .\account\models.py:38 +#: .\account\models.py:19 +msgid "Archived" +msgstr "Archivé" + +#: .\account\models.py:46 .\account\templates\account\account_list.html:12 msgid "Accounts" msgstr "Comptes" -#: .\account\templates\account\account_detail.html:13 +#: .\account\templates\account\account_detail.html:15 msgid "Edit account" msgstr "Modifier le compte" -#: .\account\templates\account\account_detail.html:16 +#: .\account\templates\account\account_detail.html:18 msgid "Statements" msgstr "Relevés" -#: .\account\templates\account\account_detail.html:20 -msgid "Transactions" -msgstr "Transactions" - -#: .\account\templates\account\account_detail.html:25 +#: .\account\templates\account\account_detail.html:24 msgid "History" msgstr "Historique" #: .\account\templates\account\account_form.html:5 +#: .\account\templates\account\account_table.html:35 msgid "Create account" msgstr "Créer un compte" #: .\account\templates\account\account_form.html:8 msgid "New account" msgstr "Nouveau compte" + +#: .\account\templates\account\account_table.html:16 +msgid "All accounts" +msgstr "Tous les comptes" + +#: .\account\templates\account\account_table.html:26 +msgid "Show archived" +msgstr "Afficher archivés" + +#~ msgid "Transactions" +#~ msgstr "Transactions" diff --git a/nummi/account/migrations/0004_alter_account_options.py b/nummi/account/migrations/0004_alter_account_options.py new file mode 100644 index 0000000..7c4fd2d --- /dev/null +++ b/nummi/account/migrations/0004_alter_account_options.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2025-01-04 17:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("account", "0003_account_archived"), + ] + + operations = [ + migrations.AlterModelOptions( + name="account", + options={ + "ordering": ["-default", "archived", "name"], + "verbose_name": "Account", + "verbose_name_plural": "Accounts", + }, + ), + ] diff --git a/nummi/account/models.py b/nummi/account/models.py index 16aca17..c1203de 100644 --- a/nummi/account/models.py +++ b/nummi/account/models.py @@ -4,10 +4,10 @@ from django.apps import apps from django.db import models from django.urls import reverse from django.utils.translation import gettext_lazy as _ -from main.models import UserModel +from main.models import NummiModel -class Account(UserModel): +class Account(NummiModel): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) name = models.CharField(max_length=64, default=_("Account"), verbose_name=_("Name")) icon = models.SlugField( @@ -41,12 +41,12 @@ class Account(UserModel): ) class Meta: - ordering = ["-default", "name"] + ordering = ["-default", "archived", "name"] verbose_name = _("Account") verbose_name_plural = _("Accounts") -class AccountModel(UserModel): +class AccountModel(NummiModel): account = models.ForeignKey( Account, on_delete=models.CASCADE, diff --git a/nummi/account/templates/account/account_detail.html b/nummi/account/templates/account/account_detail.html index 5b7fa17..6d7e408 100644 --- a/nummi/account/templates/account/account_detail.html +++ b/nummi/account/templates/account/account_detail.html @@ -22,6 +22,6 @@

{% translate "History" %}

- {% history_plot account.transactions %} + {% history_plot account.transactions account=account %}
{% endblock body %} diff --git a/nummi/account/templates/account/account_table.html b/nummi/account/templates/account/account_table.html index 0de11e9..f938ad1 100644 --- a/nummi/account/templates/account/account_table.html +++ b/nummi/account/templates/account/account_table.html @@ -1,7 +1,7 @@ {% load i18n main_extras %}
{% for acc in accounts %} -