Compare commits

..

13 commits

Author SHA1 Message Date
Mickaël Schoentgen
783b53c484
feat: Add a SITE_NAME setting and use it everywhere. 2024-12-20 23:25:56 +01:00
jjspill1
83a60b1289 Add a cli to count the number of active projects
Some checks are pending
CI / test (postgresql, normal, 3.11) (push) Blocked by required conditions
CI / test (postgresql, normal, 3.9) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.10) (push) Blocked by required conditions
CI / lint (push) Waiting to run
CI / test (mariadb, minimal, 3.11) (push) Blocked by required conditions
CI / test (mariadb, normal, 3.11) (push) Blocked by required conditions
CI / test (mariadb, normal, 3.9) (push) Blocked by required conditions
CI / test (postgresql, minimal, 3.11) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.11) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.12) (push) Blocked by required conditions
CI / test (sqlite, minimal, 3.9) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.10) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.11) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.12) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.8) (push) Blocked by required conditions
CI / test (sqlite, normal, 3.9) (push) Blocked by required conditions
CI / docs (push) Waiting to run
Docker build / test (push) Waiting to run
Docker build / build_upload (push) Blocked by required conditions
2024-12-20 18:07:51 +01:00
dependabot[bot]
ce20f9adea Update myst-parser requirement from <3,>=2 to >=2,<5
Updates the requirements on [myst-parser](https://github.com/executablebooks/MyST-Parser) to permit the latest version.
- [Release notes](https://github.com/executablebooks/MyST-Parser/releases)
- [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/MyST-Parser/compare/v2.0.0...v4.0.0)

---
updated-dependencies:
- dependency-name: myst-parser
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:46:40 +01:00
2b21795e94 ci: Pin runners to ubuntu 22.04 2024-12-20 17:46:02 +01:00
dependabot[bot]
0b09476865 Bump vermin from 1.5.2 to 1.6.0
Bumps [vermin](https://github.com/netromdk/vermin) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/netromdk/vermin/releases)
- [Commits](https://github.com/netromdk/vermin/compare/v1.5.2...v1.6.0)

---
updated-dependencies:
- dependency-name: vermin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:32:56 +01:00
dependabot[bot]
62fbeee15c Update pymysql requirement from <1.1,>=0.9 to >=0.9,<1.2
Updates the requirements on [pymysql](https://github.com/PyMySQL/PyMySQL) to permit the latest version.
- [Release notes](https://github.com/PyMySQL/PyMySQL/releases)
- [Changelog](https://github.com/PyMySQL/PyMySQL/blob/main/CHANGELOG.md)
- [Commits](https://github.com/PyMySQL/PyMySQL/compare/v0.9.0...v1.1.1)

---
updated-dependencies:
- dependency-name: pymysql
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:32:50 +01:00
dependabot[bot]
56e2ff6900 Update wtforms requirement from <3.2,>=2.3.3 to >=2.3.3,<3.3
Updates the requirements on [wtforms](https://github.com/pallets-eco/wtforms) to permit the latest version.
- [Release notes](https://github.com/pallets-eco/wtforms/releases)
- [Changelog](https://github.com/pallets-eco/wtforms/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets-eco/wtforms/compare/2.3.3...3.2.1)

---
updated-dependencies:
- dependency-name: wtforms
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:32:42 +01:00
dependabot[bot]
35ac04be20 Update flask requirement from <3,>=2 to >=2,<4
Updates the requirements on [flask](https://github.com/pallets/flask) to permit the latest version.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/2.0.0...3.1.0)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:32:32 +01:00
dependabot[bot]
a9f211d3f6 Update sphinx requirement from <8,>=7.0.1 to >=7.0.1,<9
Updates the requirements on [sphinx](https://github.com/sphinx-doc/sphinx) to permit the latest version.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/v8.1.3/CHANGES.rst)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.0.1...v8.1.3)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 17:32:17 +01:00
e568bb05cc tests: remove libfake time from the tests
libfaketime and python-libfaketime seem to cause our CI to fail when
used in conjunction with `uv`. This changes the way the tests are done
so they don't require libfaketime anymore.
2024-12-20 17:17:31 +01:00
86eb9b8662 build: remove support for python 3.7 2024-12-20 17:17:31 +01:00
6e31a9c8b5 Upgrade tooling on the project.
- Replace black by ruff, as it's quicker ;
- Use `uv` wherever possible as a replacement for pip, as it's way faster to run, add an `uv.lock` file which will be synced before the releases and published here ;
- Remove tox, it's too complex for this project and can easily be replaced by `uv` ;
- Apply `ruff` formatting ;
- Update the makefile accordingly ;
- Update the CI accordingly
2024-12-20 17:17:31 +01:00
MediMilk
cf77b4c346
Corrected typo Administation > Administration (#1332)
Some checks failed
Check doc / test_doc (push) Has been cancelled
Docker build / test (push) Has been cancelled
Lint & unit tests / lint (push) Has been cancelled
Docker build / build_upload (push) Has been cancelled
Lint & unit tests / test (mariadb, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (mariadb, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (mariadb, normal, 3.9) (push) Has been cancelled
Lint & unit tests / test (postgresql, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (postgresql, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (postgresql, normal, 3.9) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.10) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.12) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.7) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.9) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.10) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.12) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.7) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.8) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.9) (push) Has been cancelled
Co-authored-by: MediMilk <chadricksoup@gmail.com>
2024-11-16 11:55:04 +01:00
60 changed files with 2229 additions and 450 deletions

View file

@ -1,26 +0,0 @@
name: Check doc
on:
push:
branches: [ 'master', 'stable-*' ]
pull_request:
branches: [ 'master', 'stable-*' ]
jobs:
test_doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Check we can generate documentation
run: tox -e docs

View file

@ -1,4 +1,4 @@
name: Lint & unit tests name: CI
on: on:
push: push:
@ -8,26 +8,20 @@ on:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python - name: Install uv and set the python version
uses: actions/setup-python@v4 uses: astral-sh/setup-uv@v4
with: with:
python-version: "3.11" python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Run Lint - name: Run Lint
run: tox -e lint run: make lint
test: test:
# Dependency on linting to avoid running our expensive matrix test for nothing # Dependency on linting to avoid running our expensive matrix test for nothing
needs: lint needs: lint
runs-on: ubuntu-latest runs-on: ubuntu-22.04
# Use postgresql and MariaDB versions of Debian bookworm # Use postgresql and MariaDB versions of Debian bookworm
services: services:
postgres: postgres:
@ -53,10 +47,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
dependencies: [normal] dependencies: [normal]
database: [sqlite] database: [sqlite]
# Test other databases with only a few versions of Python (Debian bullseye has 3.9, bookworm has 3.11) # Test other databases with only a few versions of Python
# (Debian bullseye has 3.9, bookworm has 3.11)
include: include:
- python-version: 3.9 - python-version: 3.9
dependencies: normal dependencies: normal
@ -71,9 +66,6 @@ jobs:
dependencies: normal dependencies: normal
database: mariadb database: mariadb
# Try a few variants with the minimal versions supported # Try a few variants with the minimal versions supported
- python-version: 3.7
dependencies: minimal
database: sqlite
- python-version: 3.9 - python-version: 3.9
dependencies: minimal dependencies: minimal
database: sqlite database: sqlite
@ -95,32 +87,36 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} - name: Install uv and set the python version
uses: actions/setup-python@v4 uses: astral-sh/setup-uv@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Change dependencies to minimal supported versions - name: Change dependencies to minimal supported versions
run: sed -i -e 's/>=/==/g; s/~=.*==\(.*\)/==\1/g; s/~=/==/g;' pyproject.toml # This sed comment installs the minimal supported version
# for all versions except for "requires-python"
# This is to detect that the minimum versions are really
# supported, in the CI
run: sed -i -e '/requires-python/!s/>=/==/g; /requires-python/!s/~=.*==\(.*\)/==\1/g; /requires-python/!s/~=/==/g;' pyproject.toml
if: matrix.dependencies == 'minimal' if: matrix.dependencies == 'minimal'
- name: Install dependencies - name: Run tests
run: | run: uv run --extra dev --extra database pytest .
python -m pip install --upgrade pip
python -m pip install tox
# Run tox using the version of Python in `PATH`
- name: Run Tox with sqlite
run: tox -e py
if: matrix.database == 'sqlite'
env: env:
TESTING_SQLALCHEMY_DATABASE_URI: 'sqlite:///budget.db' # Setup the DATABASE_URI depending on the matrix we are using.
- name: Run Tox with postgresql TESTING_SQLALCHEMY_DATABASE_URI: ${{
run: tox -e py matrix.database == 'sqlite'
if: matrix.database == 'postgresql' && 'sqlite:///budget.db'
env: || matrix.database == 'postgresql'
TESTING_SQLALCHEMY_DATABASE_URI: 'postgresql+psycopg2://postgres:ihatemoney@localhost:5432/ihatemoney_ci' && 'postgresql+psycopg2://postgres:ihatemoney@localhost:5432/ihatemoney_ci'
- name: Run Tox with mariadb || 'mysql+pymysql://root:ihatemoney@localhost:3306/ihatemoney_ci'
run: tox -e py }}
if: matrix.database == 'mariadb'
env: docs:
TESTING_SQLALCHEMY_DATABASE_URI: 'mysql+pymysql://root:ihatemoney@localhost:3306/ihatemoney_ci' runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: "3.11"
- name: Build docs
run: make build-docs

View file

@ -10,7 +10,7 @@ on:
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -19,7 +19,7 @@ jobs:
run: docker compose -f docker-compose.test.yml run sut run: docker compose -f docker-compose.test.yml run sut
build_upload: build_upload:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
needs: test needs: test
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
steps: steps:

View file

@ -5,7 +5,10 @@ This document describes changes between each past release.
## 6.2.0 (unreleased) ## 6.2.0 (unreleased)
- Add support for python 3.12 (#757) - Add support for python 3.12 (#757)
- Remove support for python 3.7
- Replace the black linter by ruff
- Replace virtualenv and pip by uv
- Remove tox
## 6.1.5 (2024-03-19) ## 6.1.5 (2024-03-19)

View file

@ -1,60 +1,40 @@
VIRTUALENV = python3 -m venv VIRTUALENV = uv venv
SPHINX_BUILDDIR = docs/_build
VENV := $(shell realpath $${VIRTUAL_ENV-.venv}) VENV := $(shell realpath $${VIRTUAL_ENV-.venv})
PYTHON = $(VENV)/bin/python3 BIN := uv tool run
PIP := uv pip
PYTHON = $(BIN)/python3
DEV_STAMP = $(VENV)/.dev_env_installed.stamp DEV_STAMP = $(VENV)/.dev_env_installed.stamp
INSTALL_STAMP = $(VENV)/.install.stamp INSTALL_STAMP = $(VENV)/.install.stamp
TEMPDIR := $(shell mktemp -d) TEMPDIR := $(shell mktemp -d)
ZOPFLIPNG := zopflipng ZOPFLIPNG := zopflipng
MAGICK_MOGRIFY := mogrify MAGICK_MOGRIFY := mogrify
.PHONY: all
all: install ## Alias for install
.PHONY: install
install: virtualenv pyproject.toml $(INSTALL_STAMP) ## Install dependencies
$(INSTALL_STAMP):
$(VENV)/bin/pip install -U pip
$(VENV)/bin/pip install -e .
touch $(INSTALL_STAMP)
.PHONY: virtualenv .PHONY: virtualenv
virtualenv: $(PYTHON) virtualenv: $(PYTHON)
$(PYTHON): $(PYTHON):
$(VIRTUALENV) $(VENV) $(VIRTUALENV) $(VENV)
.PHONY: install-dev
install-dev: virtualenv pyproject.toml $(INSTALL_STAMP) $(DEV_STAMP) ## Install development dependencies
$(DEV_STAMP): $(PYTHON)
$(VENV)/bin/pip install -Ue .[dev]
touch $(DEV_STAMP)
.PHONY: remove-install-stamp
remove-install-stamp:
rm $(INSTALL_STAMP)
.PHONY: update
update: remove-install-stamp install ## Update the dependencies
.PHONY: serve .PHONY: serve
serve: install build-translations ## Run the ihatemoney server serve: build-translations ## Run the ihatemoney server
@echo 'Running ihatemoney on http://localhost:5000' @echo 'Running ihatemoney on http://localhost:5000'
FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0 FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi uv run flask run --host=0.0.0.0
.PHONY: test .PHONY: test
test: install-dev ## Run the tests test:
$(VENV)/bin/tox uv run --extra dev --extra database pytest .
.PHONY: black .PHONY: lint
black: install-dev ## Run the tests lint:
$(VENV)/bin/black --target-version=py37 . uv tool run ruff check .
uv tool run vermin --no-tips --violations -t=3.8- .
.PHONY: isort .PHONY: format
isort: install-dev ## Run the tests format:
$(VENV)/bin/isort . uv tool run ruff format .
.PHONY: release .PHONY: release
release: install-dev ## Release a new version (see https://ihatemoney.readthedocs.io/en/latest/contributing.html#how-to-release) release: # Release a new version (see https://ihatemoney.readthedocs.io/en/latest/contributing.html#how-to-release)
$(VENV)/bin/fullrelease uv run --extra dev fullreleas
.PHONY: compress-showcase .PHONY: compress-showcase
compress-showcase: compress-showcase:
@ -72,27 +52,30 @@ compress-assets: compress-showcase ## Compress static assets
.PHONY: build-translations .PHONY: build-translations
build-translations: ## Build the translations build-translations: ## Build the translations
$(VENV)/bin/pybabel compile -d ihatemoney/translations uv run --extra dev pybabel compile -d ihatemoney/translations
.PHONY: extract-translations .PHONY: extract-translations
extract-translations: ## Extract new translations from source code extract-translations: ## Extract new translations from source code
$(VENV)/bin/pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney uv run --extra dev pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney
$(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/ uv run --extra dev pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/
.PHONY: create-database-revision .PHONY: create-database-revision
create-database-revision: ## Create a new database revision create-database-revision: ## Create a new database revision
@read -p "Please enter a message describing this revision: " rev_message; \ @read -p "Please enter a message describing this revision: " rev_message; \
$(PYTHON) -m ihatemoney.manage db migrate -d ihatemoney/migrations -m "$${rev_message}" uv run python -m ihatemoney.manage db migrate -d ihatemoney/migrations -m "$${rev_message}"
.PHONY: create-empty-database-revision .PHONY: create-empty-database-revision
create-empty-database-revision: ## Create an empty database revision create-empty-database-revision: ## Create an empty database revision
@read -p "Please enter a message describing this revision: " rev_message; \ @read -p "Please enter a message describing this revision: " rev_message; \
$(PYTHON) -m ihatemoney.manage db revision -d ihatemoney/migrations -m "$${rev_message}" uv run python -m ihatemoney.manage db revision -d ihatemoney/migrations -m "$${rev_message}"
.PHONY: clean .PHONY: clean
clean: ## Destroy the virtual environment clean: ## Destroy the virtual environment
rm -rf .venv rm -rf .venv
build-docs:
uv run --extra doc sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html
.PHONY: help .PHONY: help
help: ## Show the help indications help: ## Show the help indications
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

View file

@ -22,7 +22,7 @@ highly encouraged to do so.
## Requirements ## Requirements
- **Python**: version 3.7 to 3.12. - **Python**: version 3.8 to 3.12.
- **Backends**: SQLite, PostgreSQL, MariaDB (version 10.3.2 or above), - **Backends**: SQLite, PostgreSQL, MariaDB (version 10.3.2 or above),
Memory. Memory.

View file

@ -173,6 +173,14 @@ URL you want.
- **Default value:** `""` (empty string) - **Default value:** `""` (empty string)
- **Production value:** The URL of your chosing. - **Production value:** The URL of your chosing.
## SITE_NAME
It is possible to change the name of the site to something at your liking.
- **Default value:** `"I Hate Money"` (empty string)
- **Production value:** The name of your choosing
## Configuring email sending ## Configuring email sending
By default, Ihatemoney sends emails using a local SMTP server, but it's By default, Ihatemoney sends emails using a local SMTP server, but it's

View file

@ -183,7 +183,7 @@ We are using [black](https://black.readthedocs.io/en/stable/) and
Python files in this project. Be sure to run it locally on your files. Python files in this project. Be sure to run it locally on your files.
To do so, just run: To do so, just run:
make black isort make lint
You can also integrate them with your dev environment (as a You can also integrate them with your dev environment (as a
*format-on-save* hook, for instance). *format-on-save* hook, for instance).

View file

@ -93,7 +93,7 @@ Some Paas (Platform-as-a-Service), provide a documentation or even a quick insta
«Ihatemoney» depends on: «Ihatemoney» depends on:
- **Python**: any version from 3.7 to 3.12 will work. - **Python**: any version from 3.8 to 3.12 will work.
- **A database backend**: choose among SQLite, PostgreSQL, MariaDB (>= - **A database backend**: choose among SQLite, PostgreSQL, MariaDB (>=
10.3.2). 10.3.2).
- **Virtual environment** (recommended): [python3-venv]{.title-ref} - **Virtual environment** (recommended): [python3-venv]{.title-ref}

View file

@ -3,6 +3,7 @@ DEBUG = SQLACHEMY_ECHO = False
SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/ihatemoney.db" SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/ihatemoney.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = "tralala" SECRET_KEY = "tralala"
SITE_NAME = "I Hate Money"
MAIL_DEFAULT_SENDER = "Budget manager <admin@example.com>" MAIL_DEFAULT_SENDER = "Budget manager <admin@example.com>"
SHOW_ADMIN_EMAIL = True SHOW_ADMIN_EMAIL = True
ACTIVATE_DEMO_PROJECT = True ACTIVATE_DEMO_PROJECT = True

View file

@ -90,7 +90,6 @@ def get_billform_for(project, set_default=True, **kwargs):
class CommaDecimalField(DecimalField): class CommaDecimalField(DecimalField):
"""A class to deal with comma in Decimal Field""" """A class to deal with comma in Decimal Field"""
def process_formdata(self, value): def process_formdata(self, value):

View file

@ -4,6 +4,7 @@ import getpass
import os import os
import random import random
import sys import sys
import datetime
import click import click
from flask.cli import FlaskGroup from flask.cli import FlaskGroup
@ -93,5 +94,31 @@ def delete_project(project_name):
db.session.commit() db.session.commit()
@cli.command()
@click.argument("print_emails", default=False)
@click.argument("bills", default=0) # default values will get total projects
@click.argument("days", default=73000) # approximately 200 years
def get_project_count(print_emails, bills, days):
"""Count projets with at least x bills and at less than x days old"""
projects = [
pr
for pr in Project.query.all()
if pr.get_bills().count() > bills
and pr.get_bills()[0].date
> datetime.date.today() - datetime.timedelta(days=days)
]
click.secho("Number of projects: " + str(len(projects)))
if print_emails:
emails = set([pr.contact_email for pr in projects])
emails_str = ", ".join(emails)
if len(emails) > 1:
click.secho("Contact emails: " + emails_str)
elif len(emails) == 1:
click.secho("Contact email: " + emails_str)
else:
click.secho("No contact emails found")
if __name__ == "__main__": if __name__ == "__main__":
cli() cli()

View file

@ -759,7 +759,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -103,7 +103,7 @@ def validate_configuration(app):
if "MAIL_DEFAULT_SENDER" not in app.config: if "MAIL_DEFAULT_SENDER" not in app.config:
app.config["MAIL_DEFAULT_SENDER"] = default_settings.DEFAULT_MAIL_SENDER app.config["MAIL_DEFAULT_SENDER"] = default_settings.DEFAULT_MAIL_SENDER
if type(app.config["MAIL_DEFAULT_SENDER"]) == tuple: if type(app.config["MAIL_DEFAULT_SENDER"]) is tuple:
(name, address) = app.config["MAIL_DEFAULT_SENDER"] (name, address) = app.config["MAIL_DEFAULT_SENDER"]
app.config["MAIL_DEFAULT_SENDER"] = f"{name} <{address}>" app.config["MAIL_DEFAULT_SENDER"] = f"{name} <{address}>"
warnings.warn( warnings.warn(

View file

@ -20,7 +20,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-100"> <html class="h-100">
<head> <head>
<title>I Hate Money — {{ _("Account manager") }}{% block title %}{% endblock %}</title> <title>{{ SITE_NAME }} — {{ _("Account manager") }}{% block title %}{% endblock %}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel=stylesheet type=text/css href="{{ url_for("static", filename='css/main.css') }}"> <link rel=stylesheet type=text/css href="{{ url_for("static", filename='css/main.css') }}">
@ -168,7 +168,7 @@
<i class="icon book">{{ static_include("images/book.svg") | safe }}</i> <i class="icon book">{{ static_include("images/book.svg") | safe }}</i>
</a> </a>
{% if g.show_admin_dashboard_link %} {% if g.show_admin_dashboard_link %}
<a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administation Dashboard') }}" href="{{ url_for('main.dashboard') }}"> <a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administration Dashboard') }}" href="{{ url_for('main.dashboard') }}">
<i class="icon admin">{{ static_include("images/cog.svg") | safe }}</i> <i class="icon admin">{{ static_include("images/cog.svg") | safe }}</i>
</a> </a>
{% endif %} {% endif %}

View file

@ -9,7 +9,6 @@ from ihatemoney.tests.common.ihatemoney_testcase import IhatemoneyTestCase
class TestAPI(IhatemoneyTestCase): class TestAPI(IhatemoneyTestCase):
"""Tests the API""" """Tests the API"""
def api_create( def api_create(

View file

@ -1,10 +1,9 @@
from collections import defaultdict from collections import defaultdict
import datetime from datetime import datetime, timedelta, date
import re import re
from urllib.parse import unquote, urlparse, urlunparse from urllib.parse import unquote, urlparse, urlunparse
from flask import session, url_for from flask import session, url_for
from libfaketime import fake_time
import pytest import pytest
from werkzeug.security import check_password_hash from werkzeug.security import check_password_hash
@ -239,7 +238,10 @@ class TestBudget(IhatemoneyTestCase):
url, data={"password": "pass", "password_confirmation": "pass"} url, data={"password": "pass", "password_confirmation": "pass"}
) )
resp = self.login("raclette", password="pass") resp = self.login("raclette", password="pass")
assert "<title>I Hate Money — Account manager - raclette</title>" in resp.data.decode("utf-8") assert (
"<title>I Hate Money — Account manager - raclette</title>"
in resp.data.decode("utf-8")
)
# Test empty and null tokens # Test empty and null tokens
resp = self.client.get("/reset-password") resp = self.client.get("/reset-password")
assert "No token provided" in resp.data.decode("utf-8") assert "No token provided" in resp.data.decode("utf-8")
@ -1030,9 +1032,7 @@ class TestBudget(IhatemoneyTestCase):
assert """<thead> assert """<thead>
<tr> <tr>
<th>Project</th> <th>Project</th>
<th>Number of participants</th>""" in resp.data.decode( <th>Number of participants</th>""" in resp.data.decode("utf-8")
"utf-8"
)
def test_dashboard_project_deletion(self): def test_dashboard_project_deletion(self):
self.post_project("raclette") self.post_project("raclette")
@ -1146,7 +1146,7 @@ class TestBudget(IhatemoneyTestCase):
assert re.search(re.compile(regex2, re.DOTALL), response.data.decode("utf-8")) assert re.search(re.compile(regex2, re.DOTALL), response.data.decode("utf-8"))
# Check monthly expenses again: it should have a single month and the correct amount # Check monthly expenses again: it should have a single month and the correct amount
august = datetime.date(year=2011, month=8, day=1) august = date(year=2011, month=8, day=1)
assert project.active_months_range() == [august] assert project.active_months_range() == [august]
assert dict(project.monthly_stats[2011]) == {8: 40.0} assert dict(project.monthly_stats[2011]) == {8: 40.0}
@ -1163,11 +1163,11 @@ class TestBudget(IhatemoneyTestCase):
}, },
) )
months = [ months = [
datetime.date(year=2011, month=12, day=1), date(year=2011, month=12, day=1),
datetime.date(year=2011, month=11, day=1), date(year=2011, month=11, day=1),
datetime.date(year=2011, month=10, day=1), date(year=2011, month=10, day=1),
datetime.date(year=2011, month=9, day=1), date(year=2011, month=9, day=1),
datetime.date(year=2011, month=8, day=1), date(year=2011, month=8, day=1),
] ]
amounts_2011 = { amounts_2011 = {
12: 30.0, 12: 30.0,
@ -1220,7 +1220,7 @@ class TestBudget(IhatemoneyTestCase):
"amount": "20", "amount": "20",
}, },
) )
months.append(datetime.date(year=2011, month=7, day=1)) months.append(date(year=2011, month=7, day=1))
amounts_2011[7] = 20.0 amounts_2011[7] = 20.0
assert project.active_months_range() == months assert project.active_months_range() == months
assert dict(project.monthly_stats[2011]) == amounts_2011 assert dict(project.monthly_stats[2011]) == amounts_2011
@ -1237,7 +1237,7 @@ class TestBudget(IhatemoneyTestCase):
"amount": "30", "amount": "30",
}, },
) )
months.insert(0, datetime.date(year=2012, month=1, day=1)) months.insert(0, date(year=2012, month=1, day=1))
amounts_2012 = {1: 30.0} amounts_2012 = {1: 30.0}
assert project.active_months_range() == months assert project.active_months_range() == months
assert dict(project.monthly_stats[2011]) == amounts_2011 assert dict(project.monthly_stats[2011]) == amounts_2011
@ -1870,7 +1870,6 @@ class TestBudget(IhatemoneyTestCase):
""" """
Tests that the RSS feed output content is expected. Tests that the RSS feed output content is expected.
""" """
with fake_time("2023-07-25 12:00:00"):
self.post_project("raclette", default_currency="EUR") self.post_project("raclette", default_currency="EUR")
self.client.post("/raclette/members/add", data={"name": "george"}) self.client.post("/raclette/members/add", data={"name": "george"})
self.client.post("/raclette/members/add", data={"name": "peter"}) self.client.post("/raclette/members/add", data={"name": "peter"})
@ -1917,12 +1916,10 @@ class TestBudget(IhatemoneyTestCase):
token = project.generate_token("feed") token = project.generate_token("feed")
resp = self.client.get(f"/raclette/feed/{token}.xml") resp = self.client.get(f"/raclette/feed/{token}.xml")
expected_rss_content = f"""<?xml version="1.0" encoding="utf-8"?> content = resp.data.decode()
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/" assert (
xmlns:atom="http://www.w3.org/2005/Atom" f"""<channel>
>
<channel>
<title>I Hate Money raclette</title> <title>I Hate Money raclette</title>
<description>Latest bills from raclette</description> <description>Latest bills from raclette</description>
<atom:link href="http://localhost/raclette/feed/{token}.xml" rel="self" type="application/rss+xml" /> <atom:link href="http://localhost/raclette/feed/{token}.xml" rel="self" type="application/rss+xml" />
@ -1932,32 +1929,18 @@ class TestBudget(IhatemoneyTestCase):
<guid isPermaLink="false">1</guid> <guid isPermaLink="false">1</guid>
<dc:creator>george</dc:creator> <dc:creator>george</dc:creator>
<description>December 31, 2016 - george, peter, steven : 4.00</description> <description>December 31, 2016 - george, peter, steven : 4.00</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate> """
</item> in content
<item> )
<title>charcuterie - 15.00</title>
<guid isPermaLink="false">2</guid> assert """<title>charcuterie - €15.00</title>""" in content
<dc:creator>peter</dc:creator> assert """<title>vin blanc - €10.00</title>""" in content
<description>December 30, 2016 - george, peter : 7.50</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
</item>
<item>
<title>vin blanc - 10.00</title>
<guid isPermaLink="false">3</guid>
<dc:creator>peter</dc:creator>
<description>December 29, 2016 - george, peter : 5.00</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
</item>
</channel>
</rss>""" # noqa: E221, E222, E231, E501
assert resp.data.decode() == expected_rss_content
def test_rss_feed_history_disabled(self): def test_rss_feed_history_disabled(self):
""" """
Tests that RSS feeds is correctly rendered even if the project Tests that RSS feeds is correctly rendered even if the project
history is disabled. history is disabled.
""" """
with fake_time("2023-07-25 12:00:00"):
self.post_project("raclette", default_currency="EUR", project_history=False) self.post_project("raclette", default_currency="EUR", project_history=False)
self.client.post("/raclette/members/add", data={"name": "george"}) self.client.post("/raclette/members/add", data={"name": "george"})
self.client.post("/raclette/members/add", data={"name": "peter"}) self.client.post("/raclette/members/add", data={"name": "peter"})
@ -2004,44 +1987,12 @@ class TestBudget(IhatemoneyTestCase):
token = project.generate_token("feed") token = project.generate_token("feed")
resp = self.client.get(f"/raclette/feed/{token}.xml") resp = self.client.get(f"/raclette/feed/{token}.xml")
expected_rss_content = f"""<?xml version="1.0" encoding="utf-8"?> content = resp.data.decode()
<rss version="2.0" assert """<title>charcuterie - €15.00</title>""" in content
xmlns:dc="http://purl.org/dc/elements/1.1/" assert """<title>vin blanc - €10.00</title>""" in content
xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title>I Hate Money raclette</title>
<description>Latest bills from raclette</description>
<atom:link href="http://localhost/raclette/feed/{token}.xml" rel="self" type="application/rss+xml" />
<link>http://localhost/raclette/</link>
<item>
<title>fromage à raclette - 12.00</title>
<guid isPermaLink="false">1</guid>
<dc:creator>george</dc:creator>
<description>December 31, 2016 - george, peter, steven : 4.00</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
</item>
<item>
<title>charcuterie - 15.00</title>
<guid isPermaLink="false">2</guid>
<dc:creator>peter</dc:creator>
<description>December 30, 2016 - george, peter : 7.50</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
</item>
<item>
<title>vin blanc - 10.00</title>
<guid isPermaLink="false">3</guid>
<dc:creator>peter</dc:creator>
<description>December 29, 2016 - george, peter : 5.00</description>
<pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
</item>
</channel>
</rss>""" # noqa: E221, E222, E231, E501
assert resp.data.decode() == expected_rss_content
def test_rss_if_modified_since_header(self): def test_rss_if_modified_since_header(self):
# Project creation # Project creation
with fake_time("2023-07-26 13:00:00"):
self.post_project("raclette") self.post_project("raclette")
self.client.post("/raclette/members/add", data={"name": "george"}) self.client.post("/raclette/members/add", data={"name": "george"})
project = self.get_project("raclette") project = self.get_project("raclette")
@ -2049,22 +2000,33 @@ class TestBudget(IhatemoneyTestCase):
resp = self.client.get(f"/raclette/feed/{token}.xml") resp = self.client.get(f"/raclette/feed/{token}.xml")
assert resp.status_code == 200 assert resp.status_code == 200
assert resp.headers.get("Last-Modified") == "Wed, 26 Jul 2023 13:00:00 UTC" assert "Last-Modified" in resp.headers.keys()
last_modified = resp.headers.get("Last-Modified")
# Get a date 1 hour before the last modified date
before = datetime.strptime(
last_modified, "%a, %d %b %Y %H:%M:%S %Z"
) - timedelta(hours=1)
before_str = before.strftime("%a, %d %b %Y %H:%M:%S %Z")
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={"If-Modified-Since": "Tue, 26 Jul 2023 12:00:00 UTC"}, headers={"If-Modified-Since": before_str},
) )
assert resp.status_code == 200 assert resp.status_code == 200
after = datetime.strptime(
last_modified, "%a, %d %b %Y %H:%M:%S %Z"
) + timedelta(hours=1)
after_str = after.strftime("%a, %d %b %Y %H:%M:%S %Z")
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={"If-Modified-Since": "Tue, 26 Jul 2023 14:00:00 UTC"}, headers={"If-Modified-Since": after_str},
) )
assert resp.status_code == 304 assert resp.status_code == 304
# Add bill # Add bill
with fake_time("2023-07-27 13:00:00"):
self.login("raclette") self.login("raclette")
resp = self.client.post( resp = self.client.post(
"/raclette/add", "/raclette/add",
@ -2084,38 +2046,34 @@ class TestBudget(IhatemoneyTestCase):
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={"If-Modified-Since": "Tue, 27 Jul 2023 12:00:00 UTC"}, headers={"If-Modified-Since": before_str},
) )
assert resp.headers.get("Last-Modified") == "Thu, 27 Jul 2023 13:00:00 UTC"
assert resp.status_code == 200 assert resp.status_code == 200
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={"If-Modified-Since": "Tue, 27 Jul 2023 14:00:00 UTC"}, headers={"If-Modified-Since": after_str},
) )
assert resp.status_code == 304 assert resp.status_code == 304
def test_rss_etag_headers(self): def test_rss_etag_headers(self):
# Project creation # Project creation
with fake_time("2023-07-26 13:00:00"):
self.post_project("raclette") self.post_project("raclette")
self.client.post("/raclette/members/add", data={"name": "george"}) self.client.post("/raclette/members/add", data={"name": "george"})
project = self.get_project("raclette") project = self.get_project("raclette")
token = project.generate_token("feed") token = project.generate_token("feed")
resp = self.client.get(f"/raclette/feed/{token}.xml") resp = self.client.get(f"/raclette/feed/{token}.xml")
assert resp.headers.get("ETag") == build_etag( etag = resp.headers.get("ETag")
project.id, "2023-07-26T13:00:00"
)
assert resp.status_code == 200 assert resp.status_code == 200
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={ headers={
"If-None-Match": build_etag(project.id, "2023-07-26T12:00:00"), "If-None-Match": etag,
}, },
) )
assert resp.status_code == 200 assert resp.status_code == 304
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
@ -2123,10 +2081,9 @@ class TestBudget(IhatemoneyTestCase):
"If-None-Match": build_etag(project.id, "2023-07-26T13:00:00"), "If-None-Match": build_etag(project.id, "2023-07-26T13:00:00"),
}, },
) )
assert resp.status_code == 304 assert resp.status_code == 200
# Add bill # Add bill
with fake_time("2023-07-27 13:00:00"):
self.login("raclette") self.login("raclette")
resp = self.client.post( resp = self.client.post(
"/raclette/add", "/raclette/add",
@ -2143,20 +2100,19 @@ class TestBudget(IhatemoneyTestCase):
) )
assert resp.status_code == 200 assert resp.status_code == 200
assert "The bill has been added" in resp.data.decode() assert "The bill has been added" in resp.data.decode()
etag = resp.headers.get("ETag")
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={ headers={"If-None-Match": etag},
"If-None-Match": build_etag(project.id, "2023-07-27T12:00:00"),
},
) )
assert resp.headers.get("ETag") == build_etag(project.id, "2023-07-27T13:00:00")
assert resp.status_code == 200 assert resp.status_code == 200
new_etag = resp.headers.get("ETag")
resp = self.client.get( resp = self.client.get(
f"/raclette/feed/{token}.xml", f"/raclette/feed/{token}.xml",
headers={ headers={
"If-None-Match": build_etag(project.id, "2023-07-27T13:00:00"), "If-None-Match": new_etag,
}, },
) )
assert resp.status_code == 304 assert resp.status_code == 304

View file

@ -3,6 +3,7 @@
DEBUG = False DEBUG = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db' SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db'
SQLACHEMY_ECHO = DEBUG SQLACHEMY_ECHO = DEBUG
SITE_NAME = "I Hate Money"
SECRET_KEY = "supersecret" SECRET_KEY = "supersecret"

View file

@ -3,13 +3,17 @@ import smtplib
import socket import socket
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest
from sqlalchemy import orm from sqlalchemy import orm
from werkzeug.security import check_password_hash from werkzeug.security import check_password_hash
from ihatemoney import models from ihatemoney import models
from ihatemoney.currency_convertor import CurrencyConverter from ihatemoney.currency_convertor import CurrencyConverter
from ihatemoney.manage import delete_project, generate_config, password_hash from ihatemoney.manage import (
delete_project,
generate_config,
get_project_count,
password_hash,
)
from ihatemoney.run import load_configuration from ihatemoney.run import load_configuration
from ihatemoney.tests.common.ihatemoney_testcase import BaseTestCase, IhatemoneyTestCase from ihatemoney.tests.common.ihatemoney_testcase import BaseTestCase, IhatemoneyTestCase
@ -229,6 +233,65 @@ class TestModels(IhatemoneyTestCase):
pay_each_expected = 10 / 3 pay_each_expected = 10 / 3
assert bill.pay_each() == pay_each_expected assert bill.pay_each() == pay_each_expected
def test_demo_project_count(self):
"""Test command the get-project-count"""
self.post_project("raclette")
# add members
self.client.post("/raclette/members/add", data={"name": "zorglub", "weight": 2})
self.client.post("/raclette/members/add", data={"name": "fred"})
self.client.post("/raclette/members/add", data={"name": "tata"})
self.client.post("/raclette/members/add", data={"name": "pépé"})
# create bills
self.client.post(
"/raclette/add",
data={
"date": "2011-08-10",
"what": "fromage à raclette",
"payer": 1,
"payed_for": [1, 2, 3],
"amount": "10.0",
},
)
self.client.post(
"/raclette/add",
data={
"date": "2011-08-10",
"what": "red wine",
"payer": 2,
"payed_for": [1],
"amount": "20",
},
)
assert self.get_project("raclette").has_bills()
# Now check the different parameters
runner = self.app.test_cli_runner()
result0 = runner.invoke(get_project_count)
assert result0.output.strip() == "Number of projects: 1"
# With more than 1 bill, without printing emails
result1 = runner.invoke(get_project_count, "False 1")
assert result1.output.strip() == "Number of projects: 1"
# With more than 2 bill, without printing emails
result2 = runner.invoke(get_project_count, "False 2")
assert result2.output.strip() == "Number of projects: 0"
# With more than 0 days old
result3 = runner.invoke(get_project_count, "False 0 0")
assert result3.output.strip() == "Number of projects: 0"
result4 = runner.invoke(get_project_count, "False 0 20000")
assert result4.output.strip() == "Number of projects: 1"
# Print emails
result5 = runner.invoke(get_project_count, "True")
assert "raclette@notmyidea.org" in result5.output
class TestEmailFailure(IhatemoneyTestCase): class TestEmailFailure(IhatemoneyTestCase):
def test_creation_email_failure_smtp(self): def test_creation_email_failure_smtp(self):
@ -401,9 +464,7 @@ class TestCurrencyConverter:
def test_failing_remote(self): def test_failing_remote(self):
rates = {} rates = {}
with patch("requests.Response.json", new=lambda _: {}), pytest.warns( with patch("requests.Response.json", new=lambda _: {}):
UserWarning
):
# we need a non-patched converter, but it seems that MagickMock # we need a non-patched converter, but it seems that MagickMock
# is mocking EVERY instance of the class method. Too bad. # is mocking EVERY instance of the class method. Too bad.
rates = CurrencyConverter.get_rates(self.converter) rates = CurrencyConverter.get_rates(self.converter)

View file

@ -782,7 +782,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -785,7 +785,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -826,7 +826,7 @@ msgstr "Aplicació mòbil"
msgid "Documentation" msgid "Documentation"
msgstr "Documentació" msgstr "Documentació"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Panell d'administració" msgstr "Panell d'administració"
msgid "Legal information" msgid "Legal information"

View file

@ -800,7 +800,7 @@ msgstr "Mobilní aplikace"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentace" msgstr "Dokumentace"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Správcovský panel" msgstr "Správcovský panel"
msgid "Legal information" msgid "Legal information"

View file

@ -824,7 +824,7 @@ msgstr "Handy-Applikation"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentation" msgstr "Dokumentation"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Dashboard Administration" msgstr "Dashboard Administration"
msgid "Legal information" msgid "Legal information"

View file

@ -811,7 +811,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
#, fuzzy #, fuzzy

View file

@ -821,7 +821,7 @@ msgstr "Poŝaparata programo"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentaro" msgstr "Dokumentaro"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Administra panelo" msgstr "Administra panelo"
#, fuzzy #, fuzzy

View file

@ -818,7 +818,7 @@ msgstr "Aplicación móvil"
msgid "Documentation" msgid "Documentation"
msgstr "Documentación" msgstr "Documentación"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Panel de administración" msgstr "Panel de administración"
msgid "Legal information" msgid "Legal information"

View file

@ -815,7 +815,7 @@ msgstr "Aplicación móvil"
msgid "Documentation" msgid "Documentation"
msgstr "Documentación" msgstr "Documentación"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Panel de administración" msgstr "Panel de administración"
msgid "Legal information" msgid "Legal information"

View file

@ -782,7 +782,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -824,7 +824,7 @@ msgstr "Application mobile"
msgid "Documentation" msgid "Documentation"
msgstr "Documentation" msgstr "Documentation"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Panneau d'administration" msgstr "Panneau d'administration"
msgid "Legal information" msgid "Legal information"

View file

@ -788,7 +788,7 @@ msgstr "יישום לנייד"
msgid "Documentation" msgid "Documentation"
msgstr "דוקומנטציה" msgstr "דוקומנטציה"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -829,7 +829,7 @@ msgstr "मोबाइल एप्लीकेशन"
msgid "Documentation" msgid "Documentation"
msgstr "प्रलेखन" msgstr "प्रलेखन"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "व्यवस्थापन डैशबोर्ड" msgstr "व्यवस्थापन डैशबोर्ड"
#, fuzzy #, fuzzy

View file

@ -817,7 +817,7 @@ msgstr "Mobil alkalmazás"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentáció" msgstr "Dokumentáció"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Adminisztrátori vezérlőpult" msgstr "Adminisztrátori vezérlőpult"
msgid "Legal information" msgid "Legal information"

View file

@ -812,7 +812,7 @@ msgstr "Aplikasi Gawai"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentasi" msgstr "Dokumentasi"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Dasbor Administrasi" msgstr "Dasbor Administrasi"
msgid "Legal information" msgid "Legal information"

View file

@ -817,7 +817,7 @@ msgstr "Applicazione mobile"
msgid "Documentation" msgid "Documentation"
msgstr "Documentazione" msgstr "Documentazione"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Cruscotto Amministrazione" msgstr "Cruscotto Amministrazione"
msgid "Legal information" msgid "Legal information"

View file

@ -797,7 +797,7 @@ msgstr "携帯アプリ"
msgid "Documentation" msgid "Documentation"
msgstr "書類" msgstr "書類"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "管理ダッシュボード" msgstr "管理ダッシュボード"
#, fuzzy #, fuzzy

View file

@ -793,7 +793,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -793,7 +793,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -855,7 +855,7 @@ msgstr "Mobilprogram"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentasjon" msgstr "Dokumentasjon"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Administrasjonsoversiktspanel" msgstr "Administrasjonsoversiktspanel"
#, fuzzy #, fuzzy

View file

@ -814,7 +814,7 @@ msgstr "Mobiele app"
msgid "Documentation" msgid "Documentation"
msgstr "Documentatie" msgstr "Documentatie"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Administratie-overzicht" msgstr "Administratie-overzicht"
#, fuzzy #, fuzzy

View file

@ -777,7 +777,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "Documentacion" msgstr "Documentacion"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Panèl dadministracion" msgstr "Panèl dadministracion"
msgid "Legal information" msgid "Legal information"

View file

@ -812,7 +812,7 @@ msgstr "Aplikacja mobilna"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentacja" msgstr "Dokumentacja"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Kokpit administracyjny" msgstr "Kokpit administracyjny"
msgid "Legal information" msgid "Legal information"

View file

@ -823,7 +823,7 @@ msgstr "Aplicação Mobile"
msgid "Documentation" msgid "Documentation"
msgstr "Documentação" msgstr "Documentação"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Painel de Administração" msgstr "Painel de Administração"
msgid "Legal information" msgid "Legal information"

View file

@ -809,7 +809,7 @@ msgstr "Aplicativo"
msgid "Documentation" msgid "Documentation"
msgstr "Documentação" msgstr "Documentação"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Painel de Administração" msgstr "Painel de Administração"
msgid "Legal information" msgid "Legal information"

View file

@ -816,7 +816,7 @@ msgstr "Мобильное приложение"
msgid "Documentation" msgid "Documentation"
msgstr "Документация" msgstr "Документация"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Панель инструментов администратора" msgstr "Панель инструментов администратора"
msgid "Legal information" msgid "Legal information"

View file

@ -783,7 +783,7 @@ msgstr "Mobilna Aplikacija"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentacija" msgstr "Dokumentacija"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -818,7 +818,7 @@ msgstr "Mobilapplikation"
msgid "Documentation" msgid "Documentation"
msgstr "Dokumentation" msgstr "Dokumentation"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Översiktspanel för administration" msgstr "Översiktspanel för administration"
msgid "Legal information" msgid "Legal information"

View file

@ -809,7 +809,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -817,7 +817,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -778,7 +778,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -811,7 +811,7 @@ msgstr "Telefon Uygulaması"
msgid "Documentation" msgid "Documentation"
msgstr "Belgelendirme" msgstr "Belgelendirme"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "Yönetici Gösterge Paneli" msgstr "Yönetici Gösterge Paneli"
msgid "Legal information" msgid "Legal information"

View file

@ -791,7 +791,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -776,7 +776,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -775,7 +775,7 @@ msgstr ""
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "" msgstr ""
msgid "Legal information" msgid "Legal information"

View file

@ -779,7 +779,7 @@ msgstr "手机软件"
msgid "Documentation" msgid "Documentation"
msgstr "文件" msgstr "文件"
msgid "Administation Dashboard" msgid "Administration Dashboard"
msgstr "管理面板" msgstr "管理面板"
msgid "Legal information" msgid "Legal information"

View file

@ -84,7 +84,6 @@ def flash_email_error(error_message, category="danger"):
class Redirect303(HTTPException, RoutingException): class Redirect303(HTTPException, RoutingException):
"""Raise if the map requests a redirect. This is for example the case if """Raise if the map requests a redirect. This is for example the case if
`strict_slashes` are activated and an url that requires a trailing slash. `strict_slashes` are activated and an url that requires a trailing slash.
@ -102,7 +101,6 @@ class Redirect303(HTTPException, RoutingException):
class PrefixedWSGI(object): class PrefixedWSGI(object):
""" """
Wrap the application in this middleware and configure the Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind front-end server to add these headers, to let you quietly bind

View file

@ -8,6 +8,7 @@ Basically, this blueprint takes care of the authentication and provides
some shortcuts to make your life better when coding (see `pull_project` some shortcuts to make your life better when coding (see `pull_project`
and `add_project_id` for a quick overview) and `add_project_id` for a quick overview)
""" """
import datetime import datetime
from functools import wraps from functools import wraps
import hashlib import hashlib
@ -136,6 +137,11 @@ def set_show_admin_dashboard_link(endpoint, values):
g.logout_form = LogoutForm() g.logout_form = LogoutForm()
@main.context_processor
def add_template_variables():
return {"SITE_NAME": current_app.config.get("SITE_NAME")}
@main.url_value_preprocessor @main.url_value_preprocessor
def pull_project(endpoint, values): def pull_project(endpoint, values):
"""When a request contains a project_id value, transform it directly """When a request contains a project_id value, transform it directly

View file

@ -5,6 +5,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "ihatemoney" name = "ihatemoney"
version = "6.2.0.dev0" version = "6.2.0.dev0"
requires-python = ">=3.8"
description = "A simple shared budget manager web application." description = "A simple shared budget manager web application."
readme = "README.md" readme = "README.md"
license = {file = "LICENSE"} license = {file = "LICENSE"}
@ -15,7 +16,6 @@ keywords = ["web", "budget"]
classifiers = [ classifiers = [
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
@ -30,6 +30,7 @@ dependencies = [
"cachetools>=4.1,<5", "cachetools>=4.1,<5",
"debts>=0.5,<1", "debts>=0.5,<1",
"email_validator>=1.0,<3", "email_validator>=1.0,<3",
"Flask>=2,<4",
"Flask-Babel>=1.0,<4", "Flask-Babel>=1.0,<4",
"Flask-Cors>=3.0.8,<4", "Flask-Cors>=3.0.8,<4",
"Flask-Limiter>=2.6,<3", "Flask-Limiter>=2.6,<3",
@ -39,41 +40,35 @@ dependencies = [
"Flask-SQLAlchemy>=2.4,<3", "Flask-SQLAlchemy>=2.4,<3",
"Flask-Talisman>=0.8,<2", "Flask-Talisman>=0.8,<2",
"Flask-WTF>=0.14.3,<2", "Flask-WTF>=0.14.3,<2",
"WTForms>=2.3.3,<3.2",
"Flask>=2,<3",
"Werkzeug>=2,<3",
"itsdangerous>=2,<3", "itsdangerous>=2,<3",
"Jinja2>=3,<4", "Jinja2>=3,<4",
"python-dateutil",
"qrcode>=7.1,<8", "qrcode>=7.1,<8",
"requests>=2.25,<3", "requests>=2.25,<3",
"SQLAlchemy-Continuum>=1.3.12,<2", "SQLAlchemy>=1.3.0,<1.5",
"SQLAlchemy>=1.3.0,<1.5", # New 1.4 changes API, see #728 "SQLAlchemy-Continuum>=1.3.12,<2", # New 1.4 changes API, see #728
"python-dateutil", "Werkzeug>=2,<3",
] "WTForms>=2.3.3,<3.3",]
[project.optional-dependencies] [project.optional-dependencies]
database = [ database = [
# Python 3.11 support starts in 2.9.2 # Python 3.11 support starts in 2.9.2
"psycopg2-binary>=2.9.2,<3", "psycopg2-binary>=2.9.2,<2.9.9",
"PyMySQL>=0.9,<1.1", "PyMySQL>=0.9,<1.2",
] ]
dev = [ dev = [
"black==23.3.0", "ruff==0.6.8",
"flake8==5.0.4", "flake8==5.0.4",
"isort==5.11.5", "isort==5.11.5",
"vermin==1.5.2", "vermin==1.6.0",
"pytest>=6.2.5", "pytest>=6.2.5",
"pytest-flask>=1.2.0", "pytest-flask>=1.2.0",
"pytest-libfaketime>=0.1.2",
"tox>=3.14.6",
"zest.releaser>=6.20.1", "zest.releaser>=6.20.1",
] ]
doc = [ doc = [
"Sphinx>=7.0.1,<8", "Sphinx>=7.0.1,<9",
"docutils==0.20.1", "docutils==0.20.1",
"myst-parser>=2,<3", "myst-parser>=2,<5",
] ]
[project.urls] [project.urls]
@ -107,3 +102,7 @@ include = [
"README.md", "README.md",
"SECURITY.md", "SECURITY.md",
] ]
[tool.ruff]
exclude = ["ihatemoney/migrations"]

41
tox.ini
View file

@ -1,41 +0,0 @@
[tox]
isolated_build = true
envlist = py312,py311,py310,py39,py38,py37,lint,docs
skip_missing_interpreters = True
[testenv]
passenv = TESTING_SQLALCHEMY_DATABASE_URI
commands =
python --version
py.test --pyargs ihatemoney.tests {posargs}
deps =
-e.[database,dev]
# To be sure we are importing ihatemoney pkg from pip-installed version
changedir = /tmp
[testenv:lint]
commands =
black --check --target-version=py37 .
isort --check --profile black .
flake8 ihatemoney
vermin --no-tips --violations -t=3.7- .
deps =
-e.[dev]
changedir = {toxinidir}
[testenv:docs]
commands =
sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html
deps =
-e.[doc]
changedir = {toxinidir}
[flake8]
exclude = migrations
max_line_length = 100
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,

1809
uv.lock Normal file

File diff suppressed because it is too large Load diff