From 6423c91515d947cac47a14dba350bbe571f7fcdc Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 17 Feb 2023 16:30:46 +0100 Subject: [PATCH] Ne pas lister toutes les formations d'un diplome --- app/views/admin/education/diplomas/_programs.html.erb | 9 +++++---- app/views/admin/education/diplomas/static.html.erb | 8 +++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/views/admin/education/diplomas/_programs.html.erb b/app/views/admin/education/diplomas/_programs.html.erb index 4c09f0ee6..fc7f42ca7 100644 --- a/app/views/admin/education/diplomas/_programs.html.erb +++ b/app/views/admin/education/diplomas/_programs.html.erb @@ -1,13 +1,14 @@ -<% -indentation = ' ' * depth +<% +depth ||= 2 +indentation = ' ' * depth %> <% programs.each do |program| %> <%= indentation %>- label: > <%= indentation %> <%= program.to_s %> <%= indentation %> path: "<%= program.current_permalink_in_website(@website)&.path %>" -<% children = program.children.ordered %> +<% children = program.children.where(diploma: diploma).ordered %> <% if children.any? %> <%= indentation %> children: -<%= render 'admin/education/diplomas/programs', programs: program.children.ordered, depth: depth + 4 %> +<%= render 'admin/education/diplomas/programs', diploma: diploma, programs: children, depth: depth + 4 %> <% end %> <% end %> diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb index 38deaae71..b0c0c08dc 100644 --- a/app/views/admin/education/diplomas/static.html.erb +++ b/app/views/admin/education/diplomas/static.html.erb @@ -3,12 +3,10 @@ title: > <%= prepare_text_for_static @about.name %> <%= render 'admin/application/static/permalink' if @website %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> -<% -if @website - @programs = @website.education_programs.root.ordered -%> +<% if @website + @programs = @website.education_programs.where(diploma: @about).root.ordered %> programs: -<%= render 'admin/education/diplomas/programs', programs: @programs, depth: 2 %> +<%= render 'admin/education/diplomas/programs', diploma: @about, programs: @programs %> <% end %> short_name: > <%= prepare_text_for_static @about.short_name %> -- GitLab