Commit graph

32 commits

Author SHA1 Message Date
É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
72f252b9f9 Remove f-string based translations
F-strings are a bad idea for translations, because they cause Babel to
crash when collecting strings to translate:
https://github.com/python-babel/babel/issues/715

But even if we replaced f-strings with new-style string interpolation such
as `_("{foo}").format(foo=foo)`, it's still a bad idea, because a wrong
translation can crash Ihatemoney at runtime with a KeyError.

Instead, we must really use old-style python formatting since they are
well supported in Babel.  Wrong translations that mess with string
interpolations will cause Babel to give an error when compiling
translation files, which is exactly what we want.
2023-02-03 20:35:37 +01:00
Glandos
63fba6be4c force in memory storage to remove warning
we don't need persistent storage for now
2022-12-10 18:22:41 +01:00
Glandos
e7ab3c1a95 Implement rate limiting with Flask-Limiter
Fixes #1054
2022-12-10 18:22:41 +01: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
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
7c3ced06f8
Some small cleanups (#976)
Co-authored-by: Glandos <bugs-github@antipoul.fr>
2022-01-30 15:26:22 +01:00
Baptiste Jonglez
0c8b8e9374 Remove old python 2 compatibility code 2022-01-14 19:45:02 +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
Baptiste Jonglez
4bf9308908 Add currency to import and export formats 2021-09-07 23:15:40 +02:00
Baptiste Jonglez
c69b8d66eb Use existing form errors to flash error messages
This is nice because we can reuse the translated strings of form error
messages in another context.

Suggested by Glandos.
2021-07-17 13:54:11 +02:00
Andrew Dickinson
72230448a7
Improve localization on the History page using string replacement (#587) 2021-07-12 22:48:19 +02:00
Glandos
58e5eca270
update to black 20.8b1 (#676)
Some trailing commas were removed because of some black changes.
2020-08-27 22:09:04 +02:00
zorun
df6ffc7d86
Improve error handling when sending emails (#595)
In one case, we were not catching a family of possible exceptions
(socket.error), and in the two other cases there was no error handling at
all. Sending emails can easily fail if no email server is configured, so
it is really necessary to handle these errors instead of crashing with a
HTTP 500 error.

Refactor email sending code and add proper error handling.

Show alert messages that tell the user if an email was sent or if there
was an error.

When sending a password reminder email or inviting people by email, we
don't proceed to the next step in case of error, because sending emails is
the whole point of these actions.
2020-05-21 21:13:33 +02:00
Glandos
981edd413a
Improve currencies (#604)
- Rename "No Currency" to ISO4217 "XXX"
- Use Babel to render currency symbols and names in currency lists
- Improve i18n in bill lists

Fix #601
Fix #600
2020-05-07 22:56:17 +02:00
zorun
08bb95422b
Fix crash when a localized email template is missing (#592) 2020-04-26 23:12:33 +02:00
zorun
342292ca9f
Fix language code parsing (#589) 2020-04-26 22:48:30 +02:00
Rémy HUBSCHER
299c64a48c
Add isort support. (#561) 2020-04-21 13:59:41 +02:00
Andrew Dickinson
026a072235
Add Project History Page (#553)
Co-Authored-By: Glandos <bugs-github@antipoul.fr>

All project activity can be tracked, using SQLAlchemy-continuum.
IP addresses can optionally be recorded.
2020-04-20 15:30:27 +02:00
Nicolas Vanvyve
9aa7e62d0f Import previously exported json data (#518)
Fix #417 

* New tab upload

* Extract data from JSON

* Add users

* Black format

* Try to add bill

* Import bills

* Add french translation msg

* Black reformat missing

* Deactivated users are supported

* Test import

* Remove temp file in upload_json()

* Incomplete tests

* tests import

* Update ihatemoney/translations/fr/LC_MESSAGES/messages.po

Co-Authored-By: Rémy HUBSCHER <hubscher.remy@gmail.com>

* Remove useless variable and check json format

* Use String.IO and test for wrong json

* Remove coma

Co-authored-by: Rémy HUBSCHER <hubscher.remy@gmail.com>
2020-01-13 21:17:55 +01:00
480939afe5 Remove support for python2.
In the same move :
- use a setup.cfg file for packaging
- remove the use of six
2019-10-11 19:52:37 +02:00
Brice Maron
fd49599cc7 Arrange navbar items by functions 2019-08-18 21:37:20 +00:00
Byron Ullauri
04adfe4155 Provide basic math operations on bills (#413)
* allow basic math ops in amount field for bills form
* docs: changing compile-translations to build-translations
2019-01-03 10:03:13 +01:00
Byron Ullauri
7cb339c0bb Resolve "Update API project list" (#409)
* refactoring models _to_serialize property

* updated project api members list

* addressing flake8: line too long
2018-12-26 19:07:09 +01:00
Jocelyn Delalande
d4729880dd flake8 code cleanup
Flake8 was nitpicking about:

ihatemoney/forms.py:192:13: F841 local variable 'e' is assigned to but never used
ihatemoney/utils.py:26:8: W605 invalid escape sequence '\w'
ihatemoney/utils.py:26:10: W605 invalid escape sequence '\s'
ihatemoney/utils.py:27:8: W605 invalid escape sequence '\s'
2018-11-25 21:27:04 +01:00
Alexis Métaireau
67de8c3b35 Remove unwanted space in utils.py 2018-08-05 15:02:04 +02:00
1d0880f3cb
Merge branch 'master' into almet/fix-supervisord-template 2018-07-16 22:58:48 +02:00
0livd
b93ea4830d API: Migrate from flask-rest to flask-restful (#315)
The flask-rest custom json encoder is still needed
and thus was added to ihatemoney's utils.

Closes #298
2018-01-25 17:41:28 +01:00
230eafdf58 Use Jinja2 strict rendering.
For this I had to create an Jinja2 explicit environment, so I put a
function in `ihatemoney.utils.create_jinja2_env(strict_rendering=False)`.

When using this environment and if `strict_rendering` is activated,
templates using undefined variables will now error out rather than
failing silently.
2018-01-14 18:37:10 +01:00
0livd
ec4a099f18 Protect admin endpoints against brute force attacks (#249)
* Protect admin endpoints against brute force attacks

Add a throttling mechanism to prevent a client brute
forcing the authentication form, based on its ip address
Closes #245

* Reset attempt counters if they get memory hungry
2017-08-20 12:37:12 +02:00
3a4282fd75 Absolute imports & some other improvements (#243)
* Use absolute imports and rename package to ihatemoney
* Add a ihatemoney command
* Factorize application creation logic
* Refactor the tests
* Update the wsgi.py module with the new create_app() function
* Fix some styling thanks to Flake8.
* Automate Flake8 check in the CI.
2017-07-07 00:06:56 +02:00
Renamed from budget/utils.py (Browse further)