Commit graph

136 commits

Author SHA1 Message Date
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
Baptiste Jonglez
0dede02133 Add missing __init__.py that may explain why CI fails 2022-04-03 00:28:08 +02:00
Glandos
a71f154354 Purge project history on deletion 2022-03-05 17:12:59 +01:00
Glandos
e355894cee
Check for too high values (#989)
* check for too high values

see https://github.com/python-babel/babel/issues/821

fix #957

* black & isort

* add API test
2022-02-02 10:09:49 +01:00
Glandos
07e1eac0a9
Null amount validator was broken (#990) 2022-01-30 16:33:18 +01:00
Peter Maksymowsky
a5452ccee5
Display admin email in error message for password reminder (#965)
Co-authored-by: Glandos <bugs-github@antipoul.fr>
2022-01-30 15:33:54 +01:00
Glandos
023ec71536
[Performance] Get weight sum along with bills to scale (#949)
* get weight sum along with bills to scale

otherwise, we need to get the weight sum for each displayed bill.
Here, we are much more scalable

* add test

* format

* remove unused import

* oops, restore pagination to 100

* add comments

* format

* rename method to make it clearer

And also, make it static, since it doesn't rely on instance.

* improve comments and naming

* improve naming

* missing article
2022-01-22 00:13:07 +01:00
zorun
c8cbe43ee2
Display monthly statistics for the range of months where the project was active (#885)
* Change the way we import datetime

This makes it easier to use datetime.date later.

* Display monthly statistics for the range of months where the project was active

Currently, we display a hard-coded "one year" range of monthly statistics
starting from today.  This generally is not the intended behaviour: for
instance, on an archived project, the bills might all be older than one
year, so the table only displays months without any operation.

Instead, display all months between the first and last bills.  There might
be empty months in the middle, but that's intended, because we want all
months to be consecutive.

If there are no bills, simply display an empty table.

Co-authored-by: Baptiste Jonglez <git@bitsofnetworks.org>
2022-01-18 14:32:43 +01:00
Youe Graillot
747824a298
CSV bills import (cospend compatible) (#951)
* proper import form (fix messy errors)
* csv compatible import
* cospend compatible import
* localization (best effort)
* refactoring
* revert localization (best effort)
* import return 400 on error
* fix Person.query.get_by_ids calls
* Bill explicit init parameters
* fix tests
* refacto tests with self.get_project
* separate import tests
* fix tests
* csv import test case
* fix import csv parsing
* revert DestructiveActionProjectForm renaming
* fix csv import test
* fix error redirection on import
* fix lint
* import file input type hint
* various fixes from review

Co-authored-by: Youe Graillot <youe.graillot@gmail.com>
2021-12-22 00:00:34 +01:00
Peter Maksymowsky
470c19fe4d
List supported currencies in API under api/currencies (#961)
* List supported currencies in API under api/currencies

* Added test for /currencies route
2021-12-13 23:25:25 +01:00
ef3944ccad
Send an email when the project is created via the API. (#938) 2021-11-25 00:49:17 +01:00
1698841f6d
Do not require a captcha when using the API (#931)
* Do not require a captcha when using the API

This was trickier than expected, due to some side effects : when the
captcha is set to `True` via configuration, it doesn't change the
behavior directly of the ProjectForm class, but does so only when the
project form is used in the `web.py` module.

So, when just using the API (and not using the web.py module, for
instance during tests — manual or functional), no problem was shown,
and everything was working properly.

But at soon as somebody sees the "/" endpoint, the captcha was
required, by both the API and the `web.py` module.

This fixes it by adding a way to bypass the captcha with a new
`bypass_captcha` property on the form.

Prior to this commit, things were done by activating or deactivating a
"captcha" property on the class on-the-fly, which caused side-effects.

This is now using subclasses, which makes the code simpler to
understand, and less prone to side-effects.

Thanks @zorun for the idea.
2021-11-25 00:44:21 +01:00
68552a6034
Allow connecting to upper-case project IDs. (#934)
Fix #933.
2021-11-23 19:09:50 +01:00
2adc2bf0be
Check that project creation via the API doesn't required a captcha. (#926)
Fixes #922
2021-11-21 17:39:42 +01:00