Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default owers when adding a bill #1222

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

Jojo144
Copy link
Contributor

@Jojo144 Jojo144 commented Aug 30, 2023

English

In short. Would you find nice to:

  1. either remember the owers when adding several bills
  2. or allow to define default owers in the settings of a project
    ?

(This PR implements 1.)

Français

J'utilise régulièrement IHM dans un projet où je sélectionne toujours les mêmes "Pour qui ?" quand je saisi une facture. C'est un peu long de désélectionner à chaque fois.

Est-ce que vous seriez intéressés par une des propositions suivantes :

  1. se rappeler, d'une facture sur l'autre, des derniers "Pour qui ?" sélectionnés (c'est actuellement le cas avec le "Qui a payé ?")
  2. ou permettre de définir des "Pour qui ?" par défaut dans les paramètres du projet
    ?

Ma préférence va à 1 (interface plus légère). Et vous ?

(Cette PR implémente 1.)

Comment on lines 650 to 651
bill_form.payer.data = session["last_selected_payer"]
if g.project.id in session["last_selected_payer"]:
bill_form.payer.data = session["last_selected_payer"][g.project.id]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for Flask experts:
When does the session expires? I changed the representation of session["last_selected_payer"], does the session automatically expires during an update of IHM?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the session is kept even when you update IHM, so you always need to account for the old format and convert it. This has been a frequent source of heisenbugs in the past.

In general, can you separate the two changes into separate commits/PR? One which adds the new "payed_for", and one which fixes the behaviour of payer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, can you separate the two changes into separate commits/PR?

I'll do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR. The bug fix is now in #1224 and the new feature in this PR.

@zorun zorun added improvement discussion UI/UX User Interface / User Experience labels Sep 3, 2023
@zorun
Copy link
Collaborator

zorun commented Sep 3, 2023

I like the idea, and the "simple" approach with the session looks good to me.

As said above, please separate the new feature and the fix.

You can look at adding a test (including for the fix, to avoid a regression). You can find a similar test here I believe: test_session_projects_migration_to_list

@zorun zorun changed the title [Small enhancement, Discussion] Default owers Default owers when adding a bill Sep 3, 2023
@zorun
Copy link
Collaborator

zorun commented Sep 17, 2023

Woah, all tests fail with this error: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: weight

This looks totally unrelated to your change... Can you try to rebase?

@Jojo144 Jojo144 force-pushed the default_payed_for branch 2 times, most recently from fb6f1fe to 82d9ecc Compare October 1, 2023 18:58
@zorun
Copy link
Collaborator

zorun commented Oct 1, 2023

Sorry, you need to rebase because of the tests re-organisation + the flask-wtf fix

@Jojo144 Jojo144 force-pushed the default_payed_for branch from 82d9ecc to 89f9e6f Compare October 2, 2023 17:56
@zorun
Copy link
Collaborator

zorun commented Oct 2, 2023

Can you fix the conflict?

@Jojo144 Jojo144 force-pushed the default_payed_for branch from 89f9e6f to ac3a4e5 Compare October 3, 2023 15:20
@almet almet merged commit c5c8dba into spiral-project:master Oct 3, 2023
15 checks passed
@almet
Copy link
Member

almet commented Oct 3, 2023

Perfect, thanks.

TomRoussel pushed a commit to TomRoussel/ihatemoney that referenced this pull request Mar 2, 2024
* Remember last owers for next new bill

* Add a test for last_selected_payed_for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion improvement UI/UX User Interface / User Experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants