Improve users soft deletion behaviour with RDVs
Created by: adipasquale
https://trello.com/c/aUoAmzuL/986-usersoftdelete-devrait-soccuper-des-rdvs
alternative version for #815
there was actually already a protection to avoid deleting users with RDVs but it was broken (cf commit 5) and incomplete (only dealt with future RDVs)
1. refactor: simplify user#soft_delete specs
remove freeze time and complicated dependencies
2. refactor: harmonize active scope meaning in all models
the active
scope means 'not deleted' in most models except FileAttente
and
Rdv
where it has a different meaning. This commit changes these 2 scopes names.
3. refactor: rename User#family to User#self_and_relatives_and_responsible
family
feels bad: I don't know what kind of objects it will return, and it's
unclear what it's going to include.
4. refactor: extract user#can_be_soft_deleted_from_organisation? method
preliminary iso-refactor
5. fix user#can_be_soft_deleted_from_organisation? method
The current implementation is half broken: it will only check for RDVs with strictly rdv.users == user.family. It will not match RDVs where only one member of the family is part of the RDV, whereas it should.
6. improve user soft delete alert message
- prevents beforehands actually trying to delete a user that cannot be deleted
- adds warning information when you're about to delete a user that has relatives
7. Fix Rdv List
- stop showing links to deleted users in RDV list
- fix trying to display logement for deleted users for RDVs in service social