- rename `dossiers_id_with_notifications` to `followed_dossiers_with_notifications`,
- rename `notifications_per_procedure` to `procedures_with_notifications`,
- return an ActiveRecord::Relation instead of the result of the query, so that the call place can compose it,
- `merge` with the wanted Dossier scope in the call places, don’t bother passing it as a parameter,
- use the “state” (now “scope”) parameter as a scope method that can be just applied on `Dossier`.
The code paths for deleting a dossier were different, depending on
whether the dossier was deleted by the user, or from the Manager.
This commit unifies the two code paths into one.
This has the effect of:
- An operation log is now recorded when an user deletes its own dossier;
- Gestionnaires are now notified even when the dossier is deleted from
the Manager;
- The `support:delete_user_account` task now requires the email address
of the author.
When deleting a dossier from the manager, the deletion notification
email was not being sent. This is because the returned object from
`Dossier#hide!` was invalid.
An Admin may archive a procedure to make it unavailable to
the general public, but before all dossiers are handled. In this case,
the messagerie needs to be available.
Fix#4089
* Use the existing Dossier#messagerie_available? method
* Raise when attempting to build a Commentaire if not messagerie_available?
* Disable the Messagerie form if not messagerie_available?
* Add tests :)
* Tweak the Horaires formatting while we’re here.
Sometimes, when using nested attributes, touch doesn’t propagate to
parent relationships. (see https://github.com/rails/rails/issues/26726)
Specifically, this happens in our app when updating a dossier with
only new attachements (but without changing the value of any fields).
To work around this, we need to define the parent relationship
explicitely. This is good practice anyway.
Fix#3906
Using an “inactive” Follow scope, similar to the “active” scope.
(I was tempted to use a default_scope, but this breaks when trying to `unscope` it in associations.)