diff --git a/app/models/education/program.rb b/app/models/education/program.rb index e6b00ed3587550caa491bb082d323f5d8af9fd59..a8faccd0c239d0fa839cfd3a8eac2bfe05c86fbc 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -81,8 +81,8 @@ class Education::Program < ApplicationRecord "#{name}" end - def inherited_description - description.blank? ? parent&.inherited_description : description + def best_description + description.blank? ? parent&.best_description : description end # Override from WithGithubFiles diff --git a/app/models/education/program/with_rich_texts.rb b/app/models/education/program/with_rich_texts.rb index fdc75cb0e79328b2ffd3f3c21c479784abac22ec..dc0ad2bb3cf657b1537bbe37b78de83c910c1ff4 100644 --- a/app/models/education/program/with_rich_texts.rb +++ b/app/models/education/program/with_rich_texts.rb @@ -14,48 +14,48 @@ module Education::Program::WithRichTexts has_rich_text :pricing has_rich_text :registration - def inherited_accessibility - accessibility.blank? ? parent&.inherited_accessibility : accessibility + def best_accessibility + accessibility.blank? ? parent&.best_accessibility : accessibility end - def inherited_contacts - contacts.blank? ? parent&.inherited_contacts : contacts + def best_contacts + contacts.blank? ? parent&.best_contacts : contacts end - def inherited_duration - duration.blank? ? parent&.inherited_duration : duration + def best_duration + duration.blank? ? parent&.best_duration : duration end - def inherited_evaluation - evaluation.blank? ? parent&.inherited_evaluation : evaluation + def best_evaluation + evaluation.blank? ? parent&.best_evaluation : evaluation end - def inherited_objectives - objectives.blank? ? parent&.inherited_objectives : objectives + def best_objectives + objectives.blank? ? parent&.best_objectives : objectives end - def inherited_opportunities - opportunities.blank? ? parent&.inherited_opportunities : opportunities + def best_opportunities + opportunities.blank? ? parent&.best_opportunities : opportunities end - def inherited_other - other.blank? ? parent&.inherited_other : other + def best_other + other.blank? ? parent&.best_other : other end - def inherited_pedagogy - pedagogy.blank? ? parent&.inherited_pedagogy : pedagogy + def best_pedagogy + pedagogy.blank? ? parent&.best_pedagogy : pedagogy end - def inherited_prerequisites - prerequisites.blank? ? parent&.inherited_prerequisites : prerequisites + def best_prerequisites + prerequisites.blank? ? parent&.best_prerequisites : prerequisites end - def inherited_pricing - pricing.blank? ? parent&.inherited_pricing : pricing + def best_pricing + pricing.blank? ? parent&.best_pricing : pricing end - def inherited_registration - registration.blank? ? parent&.inherited_registration : registration + def best_registration + registration.blank? ? parent&.best_registration : registration end end diff --git a/app/views/admin/administration/qualiopi/evaluations/_criterion_1.html.erb b/app/views/admin/administration/qualiopi/evaluations/_criterion_1.html.erb index 3dd779b26feeedb115f78c723205c72a5890b753..1c90768847a1c8e7802a6ab60bd1a384c9c667dc 100644 --- a/app/views/admin/administration/qualiopi/evaluations/_criterion_1.html.erb +++ b/app/views/admin/administration/qualiopi/evaluations/_criterion_1.html.erb @@ -25,7 +25,7 @@ <tr> <td><%= link_to program, [:admin, program] %></td> <% @checks.each do |check| %> - <% valid = !program.send(check).blank? %> + <% valid = !program.public_send("best_#{check}").blank? %> <th> <% if valid %> <span class="fas fa-check text-success"></span> diff --git a/app/views/admin/education/programs/jekyll.html.erb b/app/views/admin/education/programs/jekyll.html.erb index 44787cd8bd7ee73075767b1b73fcdd437a41680d..befd6e8be4b810594a82ff64b15707b86dea5a69 100644 --- a/app/views/admin/education/programs/jekyll.html.erb +++ b/app/views/admin/education/programs/jekyll.html.erb @@ -14,27 +14,27 @@ teachers: <% end %> <% end %> accessibility: > - <%= prepare_for_github @program.inherited_accessibility, @program.university %> + <%= prepare_for_github @program.best_accessibility, @program.university %> contacts: > - <%= prepare_for_github @program.inherited_contacts, @program.university %> + <%= prepare_for_github @program.best_contacts, @program.university %> description: > - <%= prepare_for_github @program.inherited_description, @program.university %> + <%= prepare_for_github @program.best_description, @program.university %> duration: > - <%= prepare_for_github @program.inherited_duration, @program.university %> + <%= prepare_for_github @program.best_duration, @program.university %> evaluation: > - <%= prepare_for_github @program.inherited_evaluation, @program.university %> + <%= prepare_for_github @program.best_evaluation, @program.university %> objectives: > - <%= prepare_for_github @program.inherited_objectives, @program.university %> + <%= prepare_for_github @program.best_objectives, @program.university %> opportunities: > - <%= prepare_for_github @program.inherited_opportunities, @program.university %> + <%= prepare_for_github @program.best_opportunities, @program.university %> other: > - <%= prepare_for_github @program.inherited_other, @program.university %> + <%= prepare_for_github @program.best_other, @program.university %> pedagogy: > - <%= prepare_for_github @program.inherited_pedagogy, @program.university %> + <%= prepare_for_github @program.best_pedagogy, @program.university %> prerequisites: > - <%= prepare_for_github @program.inherited_prerequisites, @program.university %> + <%= prepare_for_github @program.best_prerequisites, @program.university %> pricing: > - <%= prepare_for_github @program.inherited_pricing, @program.university %> + <%= prepare_for_github @program.best_pricing, @program.university %> registration: > - <%= prepare_for_github @program.inherited_registration, @program.university %> + <%= prepare_for_github @program.best_registration, @program.university %> --- diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 3d0e54f67e843123da525d1271bcb9de5499ba74..b3c016f7e06d71d726e8278b42f16be7ced3de8c 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -47,9 +47,25 @@ <div class="card-body"> <% i = 0 %> <% ['description', 'registration', 'pricing', 'duration', 'contacts', 'accessibility', 'other'].each do |prop| %> - <% next if @program.public_send(prop).blank? %> + <% + best_prop_value = @program.public_send("best_#{prop}") + prop_value = @program.public_send(prop) + %> + <% next if best_prop_value.blank? %> <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3> - <%= @program.public_send prop %> + <% if prop_value != best_prop_value %> + <% + if best_prop_value.is_a?(ActionText::RichText) + best_prop_source = best_prop_value.record + else + best_prop_source = @program.ancestors.detect { |ancestor| ancestor.public_send(prop) == best_prop_value } + end + %> + <h4 class="small text-muted"> + Par héritage (<%= link_to best_prop_source, [:admin, best_prop_source] %>) + </h4> + <% end %> + <%= best_prop_value %> <% i += 1 %> <% end %> </div>