From 5b6969891c345dd0e19bf7deec3f6a1d4b0984d5 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Fri, 5 Aug 2022 08:37:54 +0200
Subject: [PATCH] Fix #502

---
 .../admin/university/organizations_controller.rb            | 6 ++++++
 app/models/university/organization.rb                       | 1 +
 app/models/university/person.rb                             | 1 +
 app/views/admin/university/organizations/show.html.erb      | 5 +++++
 app/views/admin/university/organizations/static.html.erb    | 1 +
 app/views/admin/university/people/_main_infos.html.erb      | 1 +
 app/views/admin/university/people/static.html.erb           | 1 +
 config/routes/admin/university.rb                           | 6 +++++-
 8 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/app/controllers/admin/university/organizations_controller.rb b/app/controllers/admin/university/organizations_controller.rb
index 328dd0b54..d1b34c072 100644
--- a/app/controllers/admin/university/organizations_controller.rb
+++ b/app/controllers/admin/university/organizations_controller.rb
@@ -15,6 +15,12 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio
     breadcrumb
   end
 
+  def static
+    @about = @organization
+    @website = @organization.websites&.first
+    render layout: false
+  end
+
   def new
     breadcrumb
   end
diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb
index bfc568b5f..5fc78ebb2 100644
--- a/app/models/university/organization.rb
+++ b/app/models/university/organization.rb
@@ -36,6 +36,7 @@ class University::Organization < ApplicationRecord
   include WithBlobs
   include WithUniversity
   include WithSlug
+  include WithBlocks
 
   has_many :experiences,
            class_name: 'University::Person::Experience'
diff --git a/app/models/university/person.rb b/app/models/university/person.rb
index a3f3f3e10..91b4c2648 100644
--- a/app/models/university/person.rb
+++ b/app/models/university/person.rb
@@ -55,6 +55,7 @@ class University::Person < ApplicationRecord
   include WithSlug
   include WithPicture
   include WithRoles
+  include WithBlocks
 
   LIST_OF_ROLES = [
     :administration,
diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb
index ffeb2b8be..d78932e53 100644
--- a/app/views/admin/university/organizations/show.html.erb
+++ b/app/views/admin/university/organizations/show.html.erb
@@ -74,6 +74,7 @@
         </div>
       </div>
     </div>
+    <%= render 'admin/communication/blocks/list', about: @organization %>
   </div>
   <div class="col-md-4">
     <div class="card flex-fill w-100">
@@ -144,6 +145,10 @@
 
 <% content_for :action_bar_left do %>
   <%= destroy_link @organization %>
+  <%= link_to t('static'),
+              static_admin_university_organization_path(@organization),
+              target: :_blank,
+              class: button_classes('btn-light') if current_user.server_admin? %>
 <% end %>
 
 <% content_for :action_bar_right do %>
diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb
index 39002994c..6d79a23f7 100644
--- a/app/views/admin/university/organizations/static.html.erb
+++ b/app/views/admin/university/organizations/static.html.erb
@@ -18,5 +18,6 @@ logo: "<%= @about.logo.blob.id %>"
 <% end %>
 description: >
   <%= prepare_text_for_static @about.description %>
+<%= render 'admin/communication/blocks/static', about: @about %>
 ---
 <%= prepare_html_for_static @about.text, @about.university %>
diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb
index 0693e24ce..7cf40ec7e 100644
--- a/app/views/admin/university/people/_main_infos.html.erb
+++ b/app/views/admin/university/people/_main_infos.html.erb
@@ -61,6 +61,7 @@
         </div>
       </div>
     <% end %>
+    <%= render 'admin/communication/blocks/list', about: person %>
   </div>
   <div class="col-md-4 col-xl-3">
     <div class="card flex-fill w-100">
diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb
index 24d2039ec..a49e305b5 100644
--- a/app/views/admin/university/people/static.html.erb
+++ b/app/views/admin/university/people/static.html.erb
@@ -63,5 +63,6 @@ administrative_missions:
         <%= target.path_in_website(@website) if target.respond_to? :path_in_website %>
 <% end %>
 <% end %>
+<%= render 'admin/communication/blocks/static', about: @about %>
 ---
 <%= prepare_html_for_static @about.biography, @about.university %>
diff --git a/config/routes/admin/university.rb b/config/routes/admin/university.rb
index ce33420c9..9f4701b02 100644
--- a/config/routes/admin/university.rb
+++ b/config/routes/admin/university.rb
@@ -24,5 +24,9 @@ namespace :university do
       get :static
     end
   end
-  resources :organizations
+  resources :organizations do
+    member do
+      get :static
+    end
+  end
 end
-- 
GitLab