Merge pull request #6095 from tchak/improuve-user-destruction

Users that are experts should not be deletable
This commit is contained in:
Paul Chavard 2021-04-15 18:23:34 +01:00 committed by GitHub
commit f6c704d44d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -162,12 +162,16 @@ class User < ApplicationRecord
instructeur_id.present? instructeur_id.present?
end end
def expert?
expert_id.present?
end
def can_france_connect? def can_france_connect?
!administrateur? && !instructeur? !administrateur? && !instructeur?
end end
def can_be_deleted? def can_be_deleted?
administrateur.nil? && instructeur.nil? && dossiers.with_discarded.state_instruction_commencee.empty? !administrateur? && !instructeur? && !expert? && dossiers.with_discarded.state_instruction_commencee.empty?
end end
def delete_and_keep_track_dossiers(administration) def delete_and_keep_track_dossiers(administration)