From 203ff482e8724235d68951486cdb9b1f33df10d9 Mon Sep 17 00:00:00 2001
From: pabois <pierreandre.boissinot@noesya.coop>
Date: Mon, 22 Nov 2021 16:04:39 +0100
Subject: [PATCH] close #61

---
 .../admin/education/programs/show.html.erb    | 133 +++++++++++-------
 config/locales/education/en.yml               |   2 +-
 config/locales/education/fr.yml               |   2 +-
 3 files changed, 82 insertions(+), 55 deletions(-)

diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb
index 06c15721e..2a0a8f4cb 100644
--- a/app/views/admin/education/programs/show.html.erb
+++ b/app/views/admin/education/programs/show.html.erb
@@ -1,64 +1,91 @@
 <% content_for :title, @program %>
 
-<p>
-  <strong>Name:</strong>
-  <%= @program.name %>
-</p>
+<div class="row">
 
-<p>
-  <strong>Level:</strong>
-  <%= @program.level %>
-</p>
+  <div class="col-md-4">
+    <div class="card flex-fill w-100">
+      <div class="card-header">
+        <h2 class="card-title mb-0 h5"><%= t('education.program.main_informations') %></h2>
+      </div>
+      <div class="card-body">
+        <h3 class="h5"><%= Education::Program.human_attribute_name('name') %></h3>
+        <%= @program.name %>
+        <h3 class="h5 mt-4"><%= Education::Program.human_attribute_name('level') %></h3>
+        <%= @program.level %>
+        <h3 class="h5 mt-4"><%= Education::Program.human_attribute_name('capacity') %></h3>
+        <%= @program.capacity %>
+        <h3 class="h5 mt-4"><%= Education::Program.human_attribute_name('ects') %></h3>
+        <%= @program.ects %>
+        <h3 class="h5 mt-4"><%= Education::Program.human_attribute_name('continuing') %></h3>
+        <%= t @program.continuing %>
+        <% if @program.schools.any? %>
+          <h3 class="h5 mt-4"><%= Education::Program.human_attribute_name('schools') %></h3>
+          <ul class="list-unstyled">
+            <% @program.schools.ordered.each do |school| %>
+              <li><%= link_to_if can?(:read, school), school, [:admin, school] %></li>
+            <% end %>
+          </ul>
+        <% end %>
+      </div>
+    </div>
+  </div>
+  <div class="col-md-8">
+    <div class="card flex-fill w-100">
+      <div class="card-header">
+        <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5>
+      </div>
+      <div class="card-body">
+        <% i = 0 %>
+        <% ['registration', 'pricing', 'duration', 'contacts', 'accessibility', 'other'].each do |prop| %>
+          <% next if @program.public_send(prop).blank? %>
+          <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3>
+          <%= @program.public_send prop %>
+          <% i += 1 %>
+        <% end %>
+      </div>
+    </div>
+  </div>
+</div>
 
-<p>
-  <strong>Capacity:</strong>
-  <%= @program.capacity %>
-</p>
+<div class="card flex-fill w-100">
+  <div class="card-header">
+    <h5 class="card-title mb-0"><%= t('education.program.educational_informations') %></h5>
+  </div>
+  <div class="card-body">
+    <div class="row">
+      <div class="col-md-6">
+        <% i = 0 %>
+        <% ['prerequisites', 'objectives', 'opportunities'].each do |prop| %>
+          <% next if @program.public_send(prop).blank? %>
+          <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3>
+          <%= @program.public_send prop %>
+          <% i += 1 %>
+        <% end %>
+      </div>
+      <div class="col-md-6">
+        <% i = 0 %>
+        <% ['pedagogy', 'evaluation'].each do |prop| %>
+          <% next if @program.public_send(prop).blank? %>
+          <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name(prop) %></h3>
+          <%= @program.public_send prop %>
+          <% i += 1 %>
+        <% end %>
+        <% if @program.teachers.any? %>
+          <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name('teachers') %></h3>
+          <ul class="list-unstyled">
+            <% @program.teachers.ordered.each do |teacher| %>
+              <li><%= link_to_if can?(:read, teacher), teacher, [:admin, teacher] %></li>
+            <% end %>
+          </ul>
+        <% end %>
+      </div>
+    </div>
+  </div>
+</div>
 
-<p>
-  <strong>Ects:</strong>
-  <%= @program.ects %>
-</p>
 
-<p>
-  <strong>Continuing:</strong>
-  <%= @program.continuing %>
-</p>
 
-<p>
-  <strong>Prerequisites:</strong>
-  <%= @program.prerequisites %>
-</p>
 
-<p>
-  <strong>Objectives:</strong>
-  <%= @program.objectives %>
-</p>
-
-<p>
-  <strong>Duration:</strong>
-  <%= @program.duration %>
-</p>
-
-<p>
-  <strong>Registration:</strong>
-  <%= @program.registration %>
-</p>
-
-<p>
-  <strong>Pedagogy:</strong>
-  <%= @program.pedagogy %>
-</p>
-
-<p>
-  <strong>Evaluation:</strong>
-  <%= @program.evaluation %>
-</p>
-
-<p>
-  <strong>Accessibility:</strong>
-  <%= @program.accessibility %>
-</p>
 
 <% content_for :action_bar_right do %>
   <%= edit_link @program %>
diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml
index c2df8eaca..7dabde337 100644
--- a/config/locales/education/en.yml
+++ b/config/locales/education/en.yml
@@ -31,7 +31,7 @@ en:
         prerequisites: Prérequis
         pricing: Tarifs
         registration: Modalités et délais d’accès
-        schools: Schools
+        schools: Schools with this formation
         teachers: Teachers
       education/school:
         address: Address
diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml
index 4e0ab840a..d515a2fae 100644
--- a/config/locales/education/fr.yml
+++ b/config/locales/education/fr.yml
@@ -31,7 +31,7 @@ fr:
         prerequisites: Prérequis
         pricing: Tarifs
         registration: Modalités et délais d’accès
-        schools: Écoles
+        schools: Écoles proposant cette formation
         teachers: Enseignants·es
       education/school:
         address: Adresse
-- 
GitLab