diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb index e94145df4..bd2214eda 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -29,15 +29,7 @@ def attributive_decisions_download_button ) end - def attributive_decisions_reissue_generation_form - return unless current_establishment.with_attributive_decisions?(selected_school_year) - - render partial: "home/attributive_decision_reissue_form" - end - def attributive_decisions_generation_form - return cannot_generate_attributive_decisions_button unless current_user.can_try_to_generate_attributive_decisions? - count = current_establishment.schoolings.without_attributive_decisions .joins(:classe) .where(classe: { school_year: selected_school_year }) diff --git a/app/models/concerns/user_authorisation.rb b/app/models/concerns/user_authorisation.rb index 0c5e618b6..2cb9ec6a0 100644 --- a/app/models/concerns/user_authorisation.rb +++ b/app/models/concerns/user_authorisation.rb @@ -38,10 +38,6 @@ def cannot_validate? !can_validate? end - def can_try_to_generate_attributive_decisions? - director? - end - def can_generate_attributive_decisions? confirmed_director? end diff --git a/app/models/establishment.rb b/app/models/establishment.rb index 32621adff..604b643aa 100644 --- a/app/models/establishment.rb +++ b/app/models/establishment.rb @@ -134,7 +134,7 @@ def missing_attributive_decisions?(school_year) schoolings_for_school_year(school_year).without_attributive_decisions.any? end - def with_attributive_decisions?(school_year) + def some_attributive_decisions?(school_year) schoolings_for_school_year(school_year).with_attributive_decisions.any? end diff --git a/app/views/classes/_attributive_decisions_panel.html.haml b/app/views/classes/_attributive_decisions_panel.html.haml index 6b1931874..0c9d1403b 100644 --- a/app/views/classes/_attributive_decisions_panel.html.haml +++ b/app/views/classes/_attributive_decisions_panel.html.haml @@ -12,8 +12,9 @@ %p Les décisions d'attribution sont en train d'être éditées, veuillez rafraichir la page dans quelques minutes. Vous pouvez commencer à remplir des coordonnées bancaires ou des PFMPs pendant ce temps. - else .buttons-group - - if current_establishment.missing_attributive_decisions?(selected_school_year) && current_user.director? - = attributive_decisions_generation_form = attributive_decisions_download_button - - if current_establishment.with_attributive_decisions?(selected_school_year) && current_user.director? - = attributive_decisions_reissue_generation_form + - if current_user.director? + - if current_establishment.missing_attributive_decisions?(selected_school_year) + = attributive_decisions_generation_form + - if current_establishment.some_attributive_decisions?(selected_school_year) + = render partial: "home/attributive_decision_reissue_form" diff --git a/spec/models/establishment_spec.rb b/spec/models/establishment_spec.rb index 6be3f2e16..d9a140169 100644 --- a/spec/models/establishment_spec.rb +++ b/spec/models/establishment_spec.rb @@ -10,8 +10,8 @@ it { is_expected.to validate_uniqueness_of(:uai) } it { is_expected.to have_many(:ribs) } - describe "with_attributive_decisions?" do - subject { establishment.with_attributive_decisions?(SchoolYear.current) } + describe "some_attributive_decisions?" do + subject { establishment.some_attributive_decisions?(SchoolYear.current) } context "when there are some attributive decisions" do before { create(:schooling, :with_attributive_decision, establishment: establishment) }