Commit graph

149 commits

Author SHA1 Message Date
Michele Grimaldi
776ea9d948 Fix maintainability:
- Resolved formatting issues using isort and black.
- Updated deprecated methods (_app_ctx_stack, datetime.utcnow).
- Added a requirements.txt file for dependency management.
- Addressed Python 3. warnings (ast.Num, ast.n).
2025-01-08 21:04:06 +01:00
zorun
19ecdb5052
Change settle endpoint to use POST instead of GET (#1303)
Some checks failed
CI / lint (push) Has been cancelled
CI / docs (push) Has been cancelled
Docker build / test (push) Has been cancelled
CI / test (mariadb, minimal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.9) (push) Has been cancelled
CI / test (postgresql, minimal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.9) (push) Has been cancelled
CI / test (sqlite, minimal, 3.10) (push) Has been cancelled
CI / test (sqlite, minimal, 3.11) (push) Has been cancelled
CI / test (sqlite, minimal, 3.12) (push) Has been cancelled
CI / test (sqlite, minimal, 3.9) (push) Has been cancelled
CI / test (sqlite, normal, 3.10) (push) Has been cancelled
CI / test (sqlite, normal, 3.11) (push) Has been cancelled
CI / test (sqlite, normal, 3.12) (push) Has been cancelled
CI / test (sqlite, normal, 3.9) (push) Has been cancelled
Docker build / build_upload (push) Has been cancelled
Co-authored-by: Baptiste Jonglez <git@bitsofnetworks.org>
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
2025-01-05 22:11:41 +01:00
Mickaël Schoentgen
7505cbe25a feat: Add a SITE_NAME setting and use it everywhere.
Some checks failed
CI / lint (push) Has been cancelled
CI / docs (push) Has been cancelled
Docker build / test (push) Has been cancelled
CI / test (mariadb, minimal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.9) (push) Has been cancelled
CI / test (postgresql, minimal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.9) (push) Has been cancelled
CI / test (sqlite, minimal, 3.10) (push) Has been cancelled
CI / test (sqlite, minimal, 3.11) (push) Has been cancelled
CI / test (sqlite, minimal, 3.12) (push) Has been cancelled
CI / test (sqlite, minimal, 3.9) (push) Has been cancelled
CI / test (sqlite, normal, 3.10) (push) Has been cancelled
CI / test (sqlite, normal, 3.11) (push) Has been cancelled
CI / test (sqlite, normal, 3.12) (push) Has been cancelled
CI / test (sqlite, normal, 3.8) (push) Has been cancelled
CI / test (sqlite, normal, 3.9) (push) Has been cancelled
Docker build / build_upload (push) Has been cancelled
2024-12-20 23:27:11 +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
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
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
Éloi Rivard
3ac1bb8afe tests: cache the jinja bytecode between unit tests
The jinja templates are compiled once per test session instead of once
per test, using jinja cache system and a pytest fixture.

https://jinja.palletsprojects.com/en/3.1.x/api/#jinja2.FileSystemBytecodeCache
2024-04-16 23:11:42 +02:00
Tom Roussel
a5f83de5ce Chore: ran black 2024-03-31 19:21:56 +02:00
Tom Roussel
f9a96b0e0d Removed fromage erasure 2024-03-31 19:21:56 +02:00
Tom Roussel
a74cd97286 Removed reference to transfer billtype in test 2024-03-31 19:21:56 +02:00
Tom Roussel
a3009126dc Removed test for removed transfer billtype 2024-03-31 19:21:56 +02:00
Baptiste Jonglez
178fc94cef Fix duplicate unit tests 2024-03-25 20:46:39 +01:00
Baptiste Jonglez
312dfef14b Reformat code with black and isort 2024-03-25 20:46:39 +01:00
TomRoussel
720f0e52dd
Adding bill types and automatic settling between people (#1290)
* Bill types added in Bill and Project Model, Implemented in BillForm
* import and export bill feature updated with bill type, tests modified to reflect the behavior
* eliminating unnecessary bill type
* typo fixed, test cases fixed for the current bill types
* button added
* settle button added
* new changes
* test cases added
* bchen-reimbursement
* tests for different bill types
* test cases fixed
* fixed reimbursement test case
* Replaced assertEqual with assert
* Fixed missing bill_type in unit tests
* Removed commented code
* Reverted unnecessary string edit
* Changed bill_type to an Enum
* Added test checking correct bill_type validation
* Fixed  billtype displaying in all caps
* Removed 'Transfer' bill type
* Added migration rule and set default bill_type in alembic
* bill_type is now an optional parameter in the BillForm
* Use enum name instead of value as SQL server_default

SQLAlchemy uses the Enum names in the database, as the values could be
generic python objects.
https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.Enum

* Removed bill type from the Bills html table
* Replaced string bill type with enum
* Made "Settlement" translatable
* Manually handle the new Enum creation

Alembic does not handle postgres Enums correctly, so we need to manually
generate the new enum type.
See https://github.com/sqlalchemy/alembic/issues/278

---------

Co-authored-by: Ruitao Li <ruital@andrew.cmu.edu>
Co-authored-by: MelodyZhangYiqun <98992024+MelodyZhangYiqun@users.noreply.github.com>
Co-authored-by: Ruitao Li <49292515+FlowingCloudRTL@users.noreply.github.com>
Co-authored-by: MelodyZhangYiqun <yiqunz@andrew.cmu.edu>
Co-authored-by: Brandan Chen <bychen@andrew.cmu.edu>
Co-authored-by: Emilie Zhou <54161959+ez157@users.noreply.github.com>
Co-authored-by: Tom <tom.roussel@esat.kuleuven.be>
2024-03-16 12:20:48 +01:00
Éloi Rivard
edefb51cfb
move from setuptools to hatch (#1258)
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
2023-12-12 14:20:34 +01:00
Éloi Rivard
8bce025c15 chore: support for python 3.12 2023-11-23 23:08:39 +01:00
aab32a2c3b
Swapping Out 'Fred' for 'Jeanne' in Docs/API – Personal Peacekeeping 😊 (#1260) 2023-11-13 00:47:24 +01:00
Éloi Rivard
ee7289f5d2
chore: update to flask 2.3 (#1244)
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
2023-11-06 17:53:58 +01:00
zorun
1a2fa0476b
Currency hotfixes (#1240)
* hotfix: hardcode list of currencies to workaround failing API calls

See https://github.com/spiral-project/ihatemoney/issues/1232 for a discussion on currencies

* Temporarily disable some currency operations to prevent crashes

Here is what is disabled:

- setting or changing the default currency on an existing project

- adding or editing a bill with a currency that differs from the default
  currency of the project

---------

Co-authored-by: Baptiste Jonglez <git@bitsofnetworks.org>
2023-10-04 00:05:10 +02:00
Jojo144
c5c8dba631
Default owers when adding a bill (#1222)
* Remember last owers for next new bill

* Add a test for last_selected_payed_for
2023-10-03 20:20:58 +02:00
Jojo144
d4b178ed66 Add a test for last_selected_payer_per_project 2023-10-02 23:50:25 +02:00
Éloi Rivard
21408f8bc9 tests: migrate to pytest
- replace setUp/tearDown with pytest fixtures
- rename test classes to use the pytest convention
- use pytest assertions

Co-authored-by: Glandos <bugs-github@antipoul.fr>
2023-10-01 23:33:36 +02:00
Éloi Rivard
857ca2d5b0
tests: speed up unit tests (#1215)
Adds two configuration parameters that are passed to
generate_password_hash:

- PASSWORD_HASH_METHOD
- PASSWORD_HASH_SALT_LENGTH

The unit tests use high-speed low-security values and
gain 50% speed.
2023-08-13 00:04:06 +02:00
Baptiste Jonglez
73c8a31dd2 Invite page: document the security implication of all options
Also move the "invitation link" option first, because it's the preferred
way to give access to people that only need to handle participants and
bills.

Sharing the identifier and private becomes the last option, because it
gives full access to changing settings.
2023-07-29 14:02:49 +02:00
Baptiste Jonglez
68e1dac75c Require private code to edit a project settings
This is something we had documented in our security documentation [1], but
we didn't actually do it...

As mentioned in [1], this has good security properties: you can invite
somebody with an invitation link, and they will be able to access the
project but not change the private code (because they don't know the
current private code).

This new check also applies to all other settings (email address, history
settings, currency), which is desirable.  Only somebody with knowledge of
the private code can now change these settings.

[1] https://ihatemoney.readthedocs.io/en/latest/security.html#giving-access-to-a-project
2023-07-29 14:02:49 +02:00
Éloi Rivard
b1d4f34193
tests: unit test assertion fixes (#1203)
`self.assertTrue(200, resp.status_code)` style are always True
and thus are useless. It looks like the original author wanted
`self.assertEqual` there instead.
2023-07-28 17:44:43 +02:00
Baptiste Jonglez
db04f68652 translations: Avoid splitting strings to make translator's life easier 2023-07-28 17:20:11 +02:00
Éloi Rivard
8d4584d660 feat: project RSS feed. 2023-07-28 15:22:55 +02:00
Glandos
23d912b703
Migrate existing sessions after conversion to dict (#1194)
Migrate existing session after #1082

fix #1188
2023-07-22 19:55:45 +02:00
Glandos
d09d19af45 add test to make it fail 2023-07-15 15:27:34 +02:00
Baptiste Jonglez
bff44ae415 Avoid HTML markup in translation strings 2023-07-13 18:13:42 +02:00
Baptiste Jonglez
081f8dcf49 Allow bills with an amount of zero
Bills with an amount of zero may be useful to remember that a transaction
happened on a specific date, while the amount doesn't matter.

I use that with per-year projects when a reimbursement happens in year N
but is relative to year N-1: I record it with an amount of zero in the
project of year N, and with the real amount in the project of year N-1.

Besides, it's already possible to create such bills: while "0" is refused,
"0.0" is accepted.  There are no visible issues with this kind of bills.
2023-02-03 20:35:15 +01:00
Baptiste Jonglez
e185a157fb tests: Avoid plain "assert" and use unittest helper functions 2023-01-31 18:36:30 +01:00
Glandos
d477b41d9a add test case 2023-01-29 23:03:14 +01:00
Glandos
3a984ee206 fix test after code reformatting 2023-01-29 23:03:14 +01:00
Glandos
923a7c41c1 black formatting, since last black changed 2023-01-28 17:06:33 +01:00
Glandos
e03338e6a8 fix tests, broken by #1096
Now the "danger" strings appears nearly everywhere, but the test looks for a flash message, thus "alert-danger"
2023-01-28 17:06:33 +01:00
Glandos
9a8cc16a0b unused import 2022-12-10 18:22:41 +01:00
Glandos
4d7e966f7f fix tests 2022-12-10 18:22:41 +01:00
Glandos
24614b2c1d format doc 2022-10-22 23:02:27 +02:00
Glandos
d97123bf6b reformat 2022-10-22 23:02:27 +02:00
Glandos
cc18986b76 add test for multiple join 2022-10-22 23:02:27 +02:00
Glandos
f98b126e58 Captcha value should be case insensitive on both side (form and l10n values)
Fixes #1060
2022-09-09 22:44:27 +02:00
Glandos
78af70b2c1 Add url from request 2022-07-16 23:29:35 +02:00
Glandos
667b65b9cc
Surround email in case of error (#1044)
fix https://huntr.dev/bounties/441cc44c-6837-46ec-9b30-52455aa71a2f/
2022-07-16 23:26:51 +02:00
Glandos
31fef4f4d6
Fix CSRF on logout (#1040)
fix for https://huntr.dev/bounties/a3045614-1125-4901-bb7a-9d51be4beeed/
2022-07-14 15:45:32 +02:00
Glandos
9341dc292e fix #1037
Add a warning, so adapt the test to capture it
2022-07-10 16:07:19 +02:00
Glandos
7a55fb23fa add test to show the failure 2022-07-10 16:07:19 +02:00
Glandos
042b33aeb2 escape csv formulae
This is only needed for unsecure spreadsheet applications (hi Google Docs and MS Excel) that load formulae by default.

See https://owasp.org/www-community/attacks/CSV_Injection for some mitigation explanation. This is not complete, but it should be OK for now.
2022-05-14 16:16:12 +02:00
Glandos
5f4f69bc6c
Convert MAIL_DEFAULT_SENDER to a string (#1007)
Fixes #1005
2022-04-07 21:15:48 +02:00