From ff2c6a978e598afbe2e52efd793fff51a9353e88 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 30 Jan 2024 09:24:43 +0100
Subject: [PATCH] static

---
 .../administration/locations/static.html.erb     | 16 ++++++++++++++++
 .../admin/education/diplomas/static.html.erb     |  2 +-
 .../_static_list.html.erb}                       |  8 ++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)
 rename app/views/admin/education/{diplomas/_programs.html.erb => programs/_static_list.html.erb} (52%)

diff --git a/app/views/admin/administration/locations/static.html.erb b/app/views/admin/administration/locations/static.html.erb
index bb7429622..0e75b24c7 100644
--- a/app/views/admin/administration/locations/static.html.erb
+++ b/app/views/admin/administration/locations/static.html.erb
@@ -19,5 +19,21 @@ contact_details:
   geolocation:
     latitude: <%= @about.latitude %>
     longitude: <%= @about.longitude %>
+programs:
+<% @about.programs.each do |program| %>
+  - <%= program.path %>
+<% end %>
+diplomas:
+<% @about.diplomas.each do |diploma| %>
+  - name: >
+      <%= diploma.to_s %>
+    path: <%= diploma.slug %>
+    programs: <% @programs = @about.education_programs.where(diploma: diploma).root.ordered %>
+<%= render 'admin/education/programs/static_list', 
+            diploma: diploma, 
+            programs: @programs,
+            all_programs: @about.programs,
+            depth: 4 %>
+<% end %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb
index f904c8607..f568f2834 100644
--- a/app/views/admin/education/diplomas/static.html.erb
+++ b/app/views/admin/education/diplomas/static.html.erb
@@ -9,7 +9,7 @@ title: >
 <% if @website
   @programs = @website.education_programs.where(diploma: @about).root.ordered %>
 programs:
-<%= render 'admin/education/diplomas/programs', diploma: @about, programs: @programs %>
+<%= render 'admin/education/programs/static_list', diploma: @about, programs: @programs %>
 <% end %>
 short_name: >
   <%= prepare_text_for_static @about.short_name %>
diff --git a/app/views/admin/education/diplomas/_programs.html.erb b/app/views/admin/education/programs/_static_list.html.erb
similarity index 52%
rename from app/views/admin/education/diplomas/_programs.html.erb
rename to app/views/admin/education/programs/_static_list.html.erb
index af697c37f..831d928dc 100644
--- a/app/views/admin/education/diplomas/_programs.html.erb
+++ b/app/views/admin/education/programs/_static_list.html.erb
@@ -6,9 +6,13 @@ indentation = ' ' * depth
 <%= indentation %>- label: >
 <%= indentation %>    <%= program.to_s %>
 <%= indentation %>  path: "<%= program.current_permalink_in_website(@website)&.path %>"
-<% children = program.children.where(diploma: diploma) %>
+<% 
+children = program.children.where(diploma: diploma)
+# Limit to a global list of programs, for example on a location
+children = children.where(id: all_programs) if all_programs
+%>
 <% if children.any? %>
 <%= indentation %>  children: 
-<%= render 'admin/education/diplomas/programs', diploma: diploma, programs: children, depth: depth + 4 %>
+<%= render 'admin/education/programs/static_list', diploma: diploma, programs: children, depth: depth + 4 %>
 <% end %>
 <% end %>
-- 
GitLab