Skip to content

Commit

Permalink
Modification du code en lien avec les boutons de génération des décis…
Browse files Browse the repository at this point in the history
…ions d'attribution
  • Loading branch information
tnicolas1 committed Nov 21, 2024
1 parent 4c15d86 commit f135cbb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
8 changes: 0 additions & 8 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/user_authorisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions app/views/classes/_attributive_decisions_panel.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions spec/models/establishment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit f135cbb

Please sign in to comment.