Fix#803
On some systems, there is no configured local timezone, so LOCALTZ is
a fallback object, that don't fit use case for flask-babel.
Detect this and use 'UTC' instead
Currently, we don't display the current language in the list. This is
confusing because the list changes when switching language.
Now we always display the full list, and we highlight the current
language.
* add the event listener only once, instead of every time the form is clicked
* use a standard button by default, so that the second state with a
"danger" button is more visible
* reset confirmation button to original state when losing focus
Co-authored-by: Glandos <bugs-github@antipoul.fr>
This is the same idea as deleting a project: deleting history is also a
major destructive action. We reuse the same form as for project deletion
to ask for the private code and provide CSRF validation.
Most of the tests are using a separate database, but we have a few tests
that are loading default values and are writing to /tmp/ihatemoney.db.
This is annoying because it's also the database used for development:
running the test suite breaks the dev database.
To fix this, always use a separate testing database to avoid interference.
The previous query was working fine on sqlite and mariadb, but not on
postgresql :
return self.get_bills_unordered().group_by(Bill.original_currency).count() > 1
psycopg2.errors.GroupingError: column "bill.id" must appear in the GROUP BY clause or be used in an aggregate function
The failing SQL query was:
[SQL: SELECT count(*) AS count_1
FROM (SELECT bill.id AS bill_id, ...
FROM bill JOIN person ON person.id = bill.payer_id JOIN project ON project.id = person.project_id
WHERE bill.payer_id = person.id AND person.project_id = project.id AND project.id = %(id_1)s GROUP BY bill.original_currency) AS anon_1]
The problem is that sqlalchemy creates a subquery for postgresql, and the
internal query does not make sense.
GROUP BY is not actually useful, we simply need to count the number of
distinct currencies in the list of bills.
Currently, the private code is mandatory in the edit form, and it's not
clear whether it's meant to **check** for the right private code or to
**change** the private code.
Make the field optional and rename the help message to make it clearer
it's only meant to **change** the private code.
Also change the field type to "password" instead of simple string.
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
Currency switching is both simpler and less powerful. This was done primarily for users, to have a clear and logical understanding, but the code is also simpler. The main change is that it is now forbidden to switch a project to "no currency" if bills don't share the same currency.
Also, tests assume that projects are created without currency, as in the web UI.