From 79b79b7547c1c3875d64bdbd991321dd9adc0f48 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Sat, 21 Aug 2021 15:33:16 +0200
Subject: [PATCH] website pages draft

---
 .../website/application_controller.rb         | 18 +++++
 .../communication/website/pages_controller.rb | 60 +++++++++++++++++
 .../communication/website/pages_controller.rb | 14 ++++
 app/controllers/home_controller.rb            |  5 --
 app/models/communication/website.rb           |  1 +
 app/models/communication/website/page.rb      | 52 ++++++++++++++
 .../website/pages/_form.html.erb              | 17 +++++
 .../communication/website/pages/edit.html.erb |  3 +
 .../website/pages/index.html.erb              | 27 ++++++++
 .../communication/website/pages/new.html.erb  |  3 +
 .../communication/website/pages/show.html.erb | 20 ++++++
 .../websites/_site.json.jbuilder              |  2 -
 .../communication/websites/index.html.erb     |  2 +
 .../websites/index.json.jbuilder              |  1 -
 .../communication/websites/show.html.erb      |  9 +++
 .../communication/websites/show.json.jbuilder |  1 -
 .../education/programs/_program.json.jbuilder |  2 -
 .../education/programs/index.json.jbuilder    |  1 -
 .../education/programs/show.json.jbuilder     |  1 -
 .../universities/_university.json.jbuilder    |  2 -
 .../admin/universities/index.json.jbuilder    |  1 -
 .../admin/universities/show.json.jbuilder     |  1 -
 app/views/admin/users/_user.json.jbuilder     |  2 -
 app/views/admin/users/index.json.jbuilder     |  1 -
 app/views/admin/users/show.json.jbuilder      |  1 -
 .../_communication_website_page.json.jbuilder |  2 +
 .../website/pages/index.html.erb              | 20 ++++++
 .../website/pages/index.json.jbuilder         |  1 +
 .../communication/website/pages/show.html.erb |  3 +
 .../website/pages/show.json.jbuilder          |  1 +
 .../education/programs/_program.json.jbuilder |  2 -
 .../education/programs/index.html.erb         |  9 ---
 .../education/programs/index.json.jbuilder    |  1 -
 .../features/education/programs/show.html.erb | 67 -------------------
 .../education/programs/show.json.jbuilder     |  1 -
 .../websites/sites/_site.json.jbuilder        |  2 -
 .../features/websites/sites/index.html.erb    | 20 ------
 .../websites/sites/index.json.jbuilder        |  1 -
 .../features/websites/sites/show.html.erb     | 14 ----
 .../websites/sites/show.json.jbuilder         |  1 -
 app/views/home/index.html.erb                 |  0
 config/locales/communication/fr.yml           |  3 +
 config/routes.rb                              |  2 +-
 config/routes/admin/communication.rb          |  4 +-
 config/routes/communication.rb                |  5 +-
 config/routes/education.rb                    |  3 +-
 ...1439_create_communication_website_pages.rb | 18 +++++
 db/schema.rb                                  | 25 ++++++-
 .../website/pages_controller_test.rb          | 48 +++++++++++++
 test/fixtures/communication/website/pages.yml | 48 +++++++++++++
 .../models/communication/website/page_test.rb | 39 +++++++++++
 .../communication/website/pages_test.rb       | 53 +++++++++++++++
 52 files changed, 494 insertions(+), 146 deletions(-)
 create mode 100644 app/controllers/admin/communication/website/application_controller.rb
 create mode 100644 app/controllers/admin/communication/website/pages_controller.rb
 create mode 100644 app/controllers/communication/website/pages_controller.rb
 delete mode 100644 app/controllers/home_controller.rb
 create mode 100644 app/models/communication/website/page.rb
 create mode 100644 app/views/admin/communication/website/pages/_form.html.erb
 create mode 100644 app/views/admin/communication/website/pages/edit.html.erb
 create mode 100644 app/views/admin/communication/website/pages/index.html.erb
 create mode 100644 app/views/admin/communication/website/pages/new.html.erb
 create mode 100644 app/views/admin/communication/website/pages/show.html.erb
 delete mode 100644 app/views/admin/communication/websites/_site.json.jbuilder
 delete mode 100644 app/views/admin/communication/websites/index.json.jbuilder
 delete mode 100644 app/views/admin/communication/websites/show.json.jbuilder
 delete mode 100644 app/views/admin/education/programs/_program.json.jbuilder
 delete mode 100644 app/views/admin/education/programs/index.json.jbuilder
 delete mode 100644 app/views/admin/education/programs/show.json.jbuilder
 delete mode 100644 app/views/admin/universities/_university.json.jbuilder
 delete mode 100644 app/views/admin/universities/index.json.jbuilder
 delete mode 100644 app/views/admin/universities/show.json.jbuilder
 delete mode 100644 app/views/admin/users/_user.json.jbuilder
 delete mode 100644 app/views/admin/users/index.json.jbuilder
 delete mode 100644 app/views/admin/users/show.json.jbuilder
 create mode 100644 app/views/communication/website/pages/_communication_website_page.json.jbuilder
 create mode 100644 app/views/communication/website/pages/index.html.erb
 create mode 100644 app/views/communication/website/pages/index.json.jbuilder
 create mode 100644 app/views/communication/website/pages/show.html.erb
 create mode 100644 app/views/communication/website/pages/show.json.jbuilder
 delete mode 100644 app/views/features/education/programs/_program.json.jbuilder
 delete mode 100644 app/views/features/education/programs/index.html.erb
 delete mode 100644 app/views/features/education/programs/index.json.jbuilder
 delete mode 100644 app/views/features/education/programs/show.html.erb
 delete mode 100644 app/views/features/education/programs/show.json.jbuilder
 delete mode 100644 app/views/features/websites/sites/_site.json.jbuilder
 delete mode 100644 app/views/features/websites/sites/index.html.erb
 delete mode 100644 app/views/features/websites/sites/index.json.jbuilder
 delete mode 100644 app/views/features/websites/sites/show.html.erb
 delete mode 100644 app/views/features/websites/sites/show.json.jbuilder
 delete mode 100644 app/views/home/index.html.erb
 create mode 100644 db/migrate/20210821121439_create_communication_website_pages.rb
 create mode 100644 test/controllers/communication/website/pages_controller_test.rb
 create mode 100644 test/fixtures/communication/website/pages.yml
 create mode 100644 test/models/communication/website/page_test.rb
 create mode 100644 test/system/communication/website/pages_test.rb

diff --git a/app/controllers/admin/communication/website/application_controller.rb b/app/controllers/admin/communication/website/application_controller.rb
new file mode 100644
index 000000000..bc230a8e6
--- /dev/null
+++ b/app/controllers/admin/communication/website/application_controller.rb
@@ -0,0 +1,18 @@
+class Admin::Communication::Website::ApplicationController < Admin::Communication::ApplicationController
+  load_and_authorize_resource :website, class: Communication::Website
+
+  protected
+
+  def breadcrumb
+    super
+    add_breadcrumb Communication::Website.model_name.human(count: 2), admin_communication_websites_path(journal_id: nil)
+    breadcrumb_for @website, website_id: nil
+  end
+
+  def default_url_options
+    return {} unless params.has_key? :website_id
+    {
+      website_id: params[:website_id]
+    }
+  end
+end
diff --git a/app/controllers/admin/communication/website/pages_controller.rb b/app/controllers/admin/communication/website/pages_controller.rb
new file mode 100644
index 000000000..b644a3d90
--- /dev/null
+++ b/app/controllers/admin/communication/website/pages_controller.rb
@@ -0,0 +1,60 @@
+class Admin::Communication::Website::PagesController < Admin::Communication::Website::ApplicationController
+  load_and_authorize_resource class: Communication::Website::Page
+
+  def index
+    @pages = @website.pages
+    breadcrumb
+  end
+
+  def show
+    breadcrumb
+  end
+
+  def new
+    @page.website = @website
+    breadcrumb
+  end
+
+  def edit
+    breadcrumb
+    add_breadcrumb t('edit')
+  end
+
+  def create
+    @page.university = current_university
+    if @page.save
+      redirect_to admin_communication_website_page_path(@page), notice: "Page was successfully created."
+    else
+      breadcrumb
+      render :new, status: :unprocessable_entity
+    end
+  end
+
+  def update
+    if @page.update(page_params)
+      redirect_to admin_communication_website_page_path(@page), notice: "Page was successfully updated."
+    else
+      breadcrumb
+      render :edit, status: :unprocessable_entity
+    end
+  end
+
+  def destroy
+    redirect_to admin_communication_website_url, notice: "Page was successfully destroyed."
+  end
+
+  protected
+
+  def breadcrumb
+    super
+    add_breadcrumb Communication::Website::Page.model_name.human(count: 2), admin_communication_website_pages_path
+    breadcrumb_for @page
+  end
+
+  def page_params
+    params.require(:communication_website_page)
+          .permit(:university_id, :communication_website_id, :title,
+            :description, :about_type, :about_id, :slug, :published_at,
+            :parent_id)
+  end
+end
diff --git a/app/controllers/communication/website/pages_controller.rb b/app/controllers/communication/website/pages_controller.rb
new file mode 100644
index 000000000..5d25e0de6
--- /dev/null
+++ b/app/controllers/communication/website/pages_controller.rb
@@ -0,0 +1,14 @@
+class Communication::Website::PagesController < ApplicationController
+  def index
+    redirect_to '/admin' if is_university?
+    @page = current_website.pages.find_by path: request.path
+    if @page
+      render :show
+    else
+      @pages = current_website.pages
+    end
+  end
+
+  def show
+  end
+end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
deleted file mode 100644
index a4a109b38..000000000
--- a/app/controllers/home_controller.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class HomeController < ApplicationController
-  def index
-    redirect_to '/admin' if is_university?
-  end
-end
diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb
index b28df3e54..18f308ca1 100644
--- a/app/models/communication/website.rb
+++ b/app/models/communication/website.rb
@@ -19,6 +19,7 @@
 #
 class Communication::Website < ApplicationRecord
   belongs_to :university
+  has_many :pages, foreign_key: :communication_website_id
 
   def self.with_host(host)
     find_by domain: extract_domain_from(host)
diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb
new file mode 100644
index 000000000..ae795453d
--- /dev/null
+++ b/app/models/communication/website/page.rb
@@ -0,0 +1,52 @@
+# == Schema Information
+#
+# Table name: communication_website_pages
+#
+#  id                       :uuid             not null, primary key
+#  about_type               :string
+#  description              :text
+#  path                     :text
+#  position                 :integer          default(0), not null
+#  published_at             :datetime
+#  slug                     :string
+#  title                    :string
+#  created_at               :datetime         not null
+#  updated_at               :datetime         not null
+#  about_id                 :uuid
+#  communication_website_id :uuid             not null
+#  parent_id                :uuid
+#  university_id            :uuid             not null
+#
+# Indexes
+#
+#  index_communication_website_pages_on_about                     (about_type,about_id)
+#  index_communication_website_pages_on_communication_website_id  (communication_website_id)
+#  index_communication_website_pages_on_parent_id                 (parent_id)
+#  index_communication_website_pages_on_university_id             (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (communication_website_id => communication_websites.id)
+#  fk_rails_...  (parent_id => communication_website_pages.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+class Communication::Website::Page < ApplicationRecord
+  belongs_to :university
+  belongs_to :website, foreign_key: :communication_website_id
+  belongs_to :parent, class_name: 'Communication::Website::Page', optional: true
+  belongs_to :about, polymorphic: true, optional: true
+
+  validates :title, presence: true
+
+  before_save :make_path
+
+  def to_s
+    "#{ title }"
+  end
+
+  protected
+
+  def make_path
+    self.path = "#{parent&.path}/#{slug}"
+  end
+end
diff --git a/app/views/admin/communication/website/pages/_form.html.erb b/app/views/admin/communication/website/pages/_form.html.erb
new file mode 100644
index 000000000..687ca8ffd
--- /dev/null
+++ b/app/views/admin/communication/website/pages/_form.html.erb
@@ -0,0 +1,17 @@
+<%= simple_form_for [:admin, page] do |f| %>
+  <div class="row">
+    <div class="col-md-8">
+      <%= f.input :title %>
+      <%= f.input :slug %>
+      <%= f.input :description %>
+    </div>
+    <div class="col-md-4">
+      <%= f.input :published_at, html5: true %>
+      <%= f.association :parent, collection: page.website.pages.where.not(id: page) %>
+      <%= f.association :website, include_blank: false %>
+    </div>
+  </div>
+  <% content_for :buttons do %>
+    <%= submit f %>
+  <% end %>
+<% end %>
diff --git a/app/views/admin/communication/website/pages/edit.html.erb b/app/views/admin/communication/website/pages/edit.html.erb
new file mode 100644
index 000000000..a2efa068b
--- /dev/null
+++ b/app/views/admin/communication/website/pages/edit.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title, @page %>
+
+<%= render 'form', page: @page %>
diff --git a/app/views/admin/communication/website/pages/index.html.erb b/app/views/admin/communication/website/pages/index.html.erb
new file mode 100644
index 000000000..e79bb8f91
--- /dev/null
+++ b/app/views/admin/communication/website/pages/index.html.erb
@@ -0,0 +1,27 @@
+<% content_for :title, Communication::Website::Page.model_name.human(count: 2) %>
+
+<table class="table">
+  <thead>
+    <tr>
+      <th><%= Communication::Website::Page.human_attribute_name('title') %></th>
+      <th><%= Communication::Website::Page.human_attribute_name('parent') %></th>
+      <th></th>
+    </tr>
+  </thead>
+  <tbody>
+    <% @pages.each do |page| %>
+      <tr>
+        <td><%= link_to page, [:admin, page] %></td>
+        <td><%= link_to page.parent, [:admin, page.parent] if page.parent %></td>
+        <td class="text-end">
+          <%= edit_link page %>
+          <%= destroy_link page %>
+        </td>
+      </tr>
+    <% end %>
+  </tbody>
+</table>
+
+<% content_for :buttons do %>
+  <%= create_link Communication::Website::Page %>
+<% end %>
diff --git a/app/views/admin/communication/website/pages/new.html.erb b/app/views/admin/communication/website/pages/new.html.erb
new file mode 100644
index 000000000..4817c4565
--- /dev/null
+++ b/app/views/admin/communication/website/pages/new.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title, Research::Journal::Article.model_name.human %>
+
+<%= render 'form', page: @page %>
diff --git a/app/views/admin/communication/website/pages/show.html.erb b/app/views/admin/communication/website/pages/show.html.erb
new file mode 100644
index 000000000..eaa1bd9f1
--- /dev/null
+++ b/app/views/admin/communication/website/pages/show.html.erb
@@ -0,0 +1,20 @@
+<% content_for :title, @page %>
+
+<p>
+  <strong>Description</strong>
+  <%= @page.description %>
+</p>
+
+<p>
+  <strong>Slug</strong>
+  <%= @page.slug %>
+</p>
+
+<p>
+  <strong>Path</strong>
+  <%= @page.path %>
+</p>
+
+<% content_for :buttons do %>
+  <%= edit_link @page %>
+<% end %>
diff --git a/app/views/admin/communication/websites/_site.json.jbuilder b/app/views/admin/communication/websites/_site.json.jbuilder
deleted file mode 100644
index b66259e58..000000000
--- a/app/views/admin/communication/websites/_site.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! features_websites_site, :id, :name, :domain, :created_at, :updated_at
-json.url features_websites_site_url(features_websites_site, format: :json)
diff --git a/app/views/admin/communication/websites/index.html.erb b/app/views/admin/communication/websites/index.html.erb
index 5c8a9d022..9fbf772c3 100644
--- a/app/views/admin/communication/websites/index.html.erb
+++ b/app/views/admin/communication/websites/index.html.erb
@@ -5,6 +5,7 @@
     <tr>
       <th><%= Communication::Website.human_attribute_name('name') %></th>
       <th><%= Communication::Website.human_attribute_name('domain') %></th>
+      <th><%= Communication::Website.human_attribute_name('pages') %></th>
       <th></th>
     </tr>
   </thead>
@@ -13,6 +14,7 @@
       <tr>
         <td><%= link_to website, [:admin, website] %></td>
         <td><%= link_to website.domain_url, website.domain_url, target: :_blank %></td>
+        <td><%= website.pages.count %></td>
         <td class="text-end">
           <%= edit_link website %>
           <%= destroy_link website %>
diff --git a/app/views/admin/communication/websites/index.json.jbuilder b/app/views/admin/communication/websites/index.json.jbuilder
deleted file mode 100644
index 4eec47e61..000000000
--- a/app/views/admin/communication/websites/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @sites, partial: "admin/features/websites/sites/site", as: :site
diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb
index 6a007fa0b..7b965af6f 100644
--- a/app/views/admin/communication/websites/show.html.erb
+++ b/app/views/admin/communication/websites/show.html.erb
@@ -7,3 +7,12 @@
 <% content_for :buttons do %>
   <%= edit_link @website %>
 <% end %>
+
+<h2 class="mt-5"><%= Communication::Website::Page.model_name.human(count: 2) %></h2>
+
+<%= link_to t('create'),
+            new_admin_communication_website_page_path(website_id: @website),
+            class: button_classes %>
+
+<%= link_to 'Toutes les pages',
+            admin_communication_website_pages_path(website_id: @website) %>
diff --git a/app/views/admin/communication/websites/show.json.jbuilder b/app/views/admin/communication/websites/show.json.jbuilder
deleted file mode 100644
index 4073c7237..000000000
--- a/app/views/admin/communication/websites/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "features_websites_sites/features_websites_site", features_websites_site: @features_websites_site
diff --git a/app/views/admin/education/programs/_program.json.jbuilder b/app/views/admin/education/programs/_program.json.jbuilder
deleted file mode 100644
index 7d5775512..000000000
--- a/app/views/admin/education/programs/_program.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! program, :id, :university_id, :name, :level, :capacity, :ects, :continuing, :prerequisites, :objectives, :duration, :registration, :pedagogy, :evaluation, :accessibility, :created_at, :updated_at
-json.url program_url(program, format: :json)
diff --git a/app/views/admin/education/programs/index.json.jbuilder b/app/views/admin/education/programs/index.json.jbuilder
deleted file mode 100644
index 15edaff7d..000000000
--- a/app/views/admin/education/programs/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @programs, partial: "admin/features/education/programs/program", as: :program
diff --git a/app/views/admin/education/programs/show.json.jbuilder b/app/views/admin/education/programs/show.json.jbuilder
deleted file mode 100644
index 8053e7aed..000000000
--- a/app/views/admin/education/programs/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "programs/program", program: @program
diff --git a/app/views/admin/universities/_university.json.jbuilder b/app/views/admin/universities/_university.json.jbuilder
deleted file mode 100644
index 9b20654a6..000000000
--- a/app/views/admin/universities/_university.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! university, :id, :name, :address, :zipcode, :city, :country, :private, :created_at, :updated_at
-json.url university_url(university, format: :json)
diff --git a/app/views/admin/universities/index.json.jbuilder b/app/views/admin/universities/index.json.jbuilder
deleted file mode 100644
index 93258cd65..000000000
--- a/app/views/admin/universities/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @universities, partial: "universities/university", as: :university
diff --git a/app/views/admin/universities/show.json.jbuilder b/app/views/admin/universities/show.json.jbuilder
deleted file mode 100644
index c8b159aca..000000000
--- a/app/views/admin/universities/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "universities/university", university: @university
diff --git a/app/views/admin/users/_user.json.jbuilder b/app/views/admin/users/_user.json.jbuilder
deleted file mode 100644
index a6642dbdf..000000000
--- a/app/views/admin/users/_user.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! user, :id, :first_name, :last_name, :role, :created_at, :updated_at
-json.url user_url(user, format: :json)
diff --git a/app/views/admin/users/index.json.jbuilder b/app/views/admin/users/index.json.jbuilder
deleted file mode 100644
index 98788dadd..000000000
--- a/app/views/admin/users/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @users, partial: "users/user", as: :user
diff --git a/app/views/admin/users/show.json.jbuilder b/app/views/admin/users/show.json.jbuilder
deleted file mode 100644
index ff40bb960..000000000
--- a/app/views/admin/users/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "users/user", user: @user
diff --git a/app/views/communication/website/pages/_communication_website_page.json.jbuilder b/app/views/communication/website/pages/_communication_website_page.json.jbuilder
new file mode 100644
index 000000000..76353d73c
--- /dev/null
+++ b/app/views/communication/website/pages/_communication_website_page.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! communication_website_page, :id, :university_id, :communication_website_id, :title, :description, :kind, :about_id, :created_at, :updated_at
+json.url communication_website_page_url(communication_website_page, format: :json)
diff --git a/app/views/communication/website/pages/index.html.erb b/app/views/communication/website/pages/index.html.erb
new file mode 100644
index 000000000..d3ac7cc09
--- /dev/null
+++ b/app/views/communication/website/pages/index.html.erb
@@ -0,0 +1,20 @@
+<% content_for :title, Communication::Website::Page.model_name.human(count: 2) %>
+
+<table class="table">
+  <thead>
+    <tr>
+      <th>Title</th>
+      <th>Description</th>
+      <th>Path</th>
+    </tr>
+  </thead>
+  <tbody>
+    <% @pages.each do |page| %>
+      <tr>
+        <td><%= link_to page, page %></td>
+        <td><%= page.description %></td>
+        <td><%= page.path %></td>
+      </tr>
+    <% end %>
+  </tbody>
+</table>
diff --git a/app/views/communication/website/pages/index.json.jbuilder b/app/views/communication/website/pages/index.json.jbuilder
new file mode 100644
index 000000000..1f1ff9a1a
--- /dev/null
+++ b/app/views/communication/website/pages/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @communication_website_pages, partial: "communication_website_pages/communication_website_page", as: :communication_website_page
diff --git a/app/views/communication/website/pages/show.html.erb b/app/views/communication/website/pages/show.html.erb
new file mode 100644
index 000000000..0a4c0bc99
--- /dev/null
+++ b/app/views/communication/website/pages/show.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title, @page %>
+
+<%= @page.description %>
diff --git a/app/views/communication/website/pages/show.json.jbuilder b/app/views/communication/website/pages/show.json.jbuilder
new file mode 100644
index 000000000..56fa105a1
--- /dev/null
+++ b/app/views/communication/website/pages/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "communication_website_pages/communication_website_page", communication_website_page: @communication_website_page
diff --git a/app/views/features/education/programs/_program.json.jbuilder b/app/views/features/education/programs/_program.json.jbuilder
deleted file mode 100644
index ff41a9f2a..000000000
--- a/app/views/features/education/programs/_program.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! program, :id, :university_id, :name, :level, :capacity, :ects, :continuing, :prerequisites, :objectives, :duration, :registration, :pedagogy, :evaluation, :accessibility, :created_at, :updated_at
-json.url features_education_program_url(program, format: :json)
diff --git a/app/views/features/education/programs/index.html.erb b/app/views/features/education/programs/index.html.erb
deleted file mode 100644
index 4ce8c0e76..000000000
--- a/app/views/features/education/programs/index.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<%= content_for :title, Features::Education::Program.model_name.human(count: 2) %>
-
-<h1><%= Features::Education::Program.model_name.human(count: 2) %></h1>
-
-<ul>
-  <% @programs.each do |program| %>
-    <li><%= link_to program, program %></li>
-  <% end %>
-</ul>
diff --git a/app/views/features/education/programs/index.json.jbuilder b/app/views/features/education/programs/index.json.jbuilder
deleted file mode 100644
index 40e26f1fc..000000000
--- a/app/views/features/education/programs/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @programs, partial: "features/education/programs/program", as: :program
diff --git a/app/views/features/education/programs/show.html.erb b/app/views/features/education/programs/show.html.erb
deleted file mode 100644
index 8e8f80906..000000000
--- a/app/views/features/education/programs/show.html.erb
+++ /dev/null
@@ -1,67 +0,0 @@
-<%= content_for :title, @program %>
-<h1><%= @program %></h1>
-
-<p>
-  <strong>University:</strong>
-  <%= @program.university %>
-</p>
-
-<p>
-  <strong>Name:</strong>
-  <%= @program.name %>
-</p>
-
-<p>
-  <strong>Level:</strong>
-  <%= @program.level %>
-</p>
-
-<p>
-  <strong>Capacity:</strong>
-  <%= @program.capacity %>
-</p>
-
-<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>
diff --git a/app/views/features/education/programs/show.json.jbuilder b/app/views/features/education/programs/show.json.jbuilder
deleted file mode 100644
index 0794afbe5..000000000
--- a/app/views/features/education/programs/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "features/education/programs/program", program: @program
diff --git a/app/views/features/websites/sites/_site.json.jbuilder b/app/views/features/websites/sites/_site.json.jbuilder
deleted file mode 100644
index 8739db549..000000000
--- a/app/views/features/websites/sites/_site.json.jbuilder
+++ /dev/null
@@ -1,2 +0,0 @@
-json.extract! site, :id, :name, :domain, :created_at, :updated_at
-json.url features_websites_site_url(features_websites_site, format: :json)
diff --git a/app/views/features/websites/sites/index.html.erb b/app/views/features/websites/sites/index.html.erb
deleted file mode 100644
index 845c56237..000000000
--- a/app/views/features/websites/sites/index.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-<%= content_for :title, Features::Websites::Site.model_name.human(count: 2) %>
-
-<h1><%= Features::Websites::Site.model_name.human(count: 2) %></h1>
-
-<table class="table">
-  <thead>
-    <tr>
-      <th>Name</th>
-      <th>Domain</th>
-    </tr>
-  </thead>
-  <tbody>
-    <% @sites.each do |site| %>
-      <tr>
-        <td><%= site.name %></td>
-        <td><%= link_to site.domain_url, site.domain_url, target: :_blank %></td>
-      </tr>
-    <% end %>
-  </tbody>
-</table>
diff --git a/app/views/features/websites/sites/index.json.jbuilder b/app/views/features/websites/sites/index.json.jbuilder
deleted file mode 100644
index a0f8a96f0..000000000
--- a/app/views/features/websites/sites/index.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.array! @sites, partial: "features/websites/sites/site", as: :site
diff --git a/app/views/features/websites/sites/show.html.erb b/app/views/features/websites/sites/show.html.erb
deleted file mode 100644
index 6723461de..000000000
--- a/app/views/features/websites/sites/show.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
-  <strong>Name:</strong>
-  <%= @features_websites_site.name %>
-</p>
-
-<p>
-  <strong>Domain:</strong>
-  <%= @features_websites_site.domain %>
-</p>
-
-<%= link_to 'Edit', edit_features_websites_site_path(@features_websites_site) %> |
-<%= link_to 'Back', features_websites_sites_path %>
diff --git a/app/views/features/websites/sites/show.json.jbuilder b/app/views/features/websites/sites/show.json.jbuilder
deleted file mode 100644
index d7da0c822..000000000
--- a/app/views/features/websites/sites/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.partial! "features/websites/sites/site", site: @site
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb
deleted file mode 100644
index e69de29bb..000000000
diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml
index c9816c4c8..474e8cd1c 100644
--- a/config/locales/communication/fr.yml
+++ b/config/locales/communication/fr.yml
@@ -7,6 +7,9 @@ fr:
       communication/website:
         one: Site Web
         other: Sites Web
+      communication/website/page:
+        one: Page
+        other: Pages
     attributes:
       communication/website:
         name: Nom
diff --git a/config/routes.rb b/config/routes.rb
index 64f30c95c..a77f1b43c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,5 +12,5 @@ Rails.application.routes.draw do
   draw 'communication'
   draw 'administration'
 
-  root to: 'home#index'
+  root to: 'communication/website/pages#index'
 end
diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb
index 2d2dfc63f..2568a3265 100644
--- a/config/routes/admin/communication.rb
+++ b/config/routes/admin/communication.rb
@@ -1,3 +1,5 @@
 namespace :communication do
-  resources :websites
+  resources :websites do
+    resources :pages, controller: 'website/pages'
+  end
 end
diff --git a/config/routes/communication.rb b/config/routes/communication.rb
index 8e4cafcbf..8cb89f645 100644
--- a/config/routes/communication.rb
+++ b/config/routes/communication.rb
@@ -1,4 +1,5 @@
 namespace :communication do
-  resources :websites
-  root to: 'websites#index'
+  namespace :website do
+    resources :pages, only: [:index, :show]
+  end
 end
diff --git a/config/routes/education.rb b/config/routes/education.rb
index 245491d6b..ff0e30c2f 100644
--- a/config/routes/education.rb
+++ b/config/routes/education.rb
@@ -1,4 +1,3 @@
 namespace :education do
-  resources :programs
-  root to: 'programs#index'
+  resources :programs, only: [:index, :show]
 end
diff --git a/db/migrate/20210821121439_create_communication_website_pages.rb b/db/migrate/20210821121439_create_communication_website_pages.rb
new file mode 100644
index 000000000..322f38f50
--- /dev/null
+++ b/db/migrate/20210821121439_create_communication_website_pages.rb
@@ -0,0 +1,18 @@
+class CreateCommunicationWebsitePages < ActiveRecord::Migration[6.1]
+  def change
+    create_table :communication_website_pages, id: :uuid do |t|
+      t.references :university, null: false, foreign_key: true, type: :uuid
+      t.references :communication_website, null: false, foreign_key: true, type: :uuid
+      t.string :title
+      t.text :description
+      t.string :slug
+      t.text :path
+      t.datetime :published_at
+      t.references :parent, foreign_key: {to_table: :communication_website_pages}, type: :uuid
+      t.integer :position, default: 0, null: false
+      t.references :about, polymorphic: true, type: :uuid
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 26acb79ac..375624afe 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2021_08_17_125119) do
+ActiveRecord::Schema.define(version: 2021_08_21_121439) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "pgcrypto"
@@ -38,6 +38,26 @@ ActiveRecord::Schema.define(version: 2021_08_17_125119) do
     t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id"
   end
 
+  create_table "communication_website_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.uuid "university_id", null: false
+    t.uuid "communication_website_id", null: false
+    t.string "title"
+    t.text "description"
+    t.string "slug"
+    t.text "path"
+    t.datetime "published_at"
+    t.uuid "parent_id"
+    t.integer "position", default: 0, null: false
+    t.string "about_type"
+    t.uuid "about_id"
+    t.datetime "created_at", precision: 6, null: false
+    t.datetime "updated_at", precision: 6, null: false
+    t.index ["about_type", "about_id"], name: "index_communication_website_pages_on_about"
+    t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id"
+    t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id"
+    t.index ["university_id"], name: "index_communication_website_pages_on_university_id"
+  end
+
   create_table "communication_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.string "name"
@@ -147,6 +167,9 @@ ActiveRecord::Schema.define(version: 2021_08_17_125119) do
   end
 
   add_foreign_key "administration_qualiopi_indicators", "administration_qualiopi_criterions", column: "criterion_id"
+  add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id"
+  add_foreign_key "communication_website_pages", "communication_websites"
+  add_foreign_key "communication_website_pages", "universities"
   add_foreign_key "communication_websites", "universities"
   add_foreign_key "education_programs", "universities"
   add_foreign_key "research_journal_articles", "research_journal_volumes"
diff --git a/test/controllers/communication/website/pages_controller_test.rb b/test/controllers/communication/website/pages_controller_test.rb
new file mode 100644
index 000000000..ddd048ecc
--- /dev/null
+++ b/test/controllers/communication/website/pages_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class Communication::Website::PagesControllerTest < ActionDispatch::IntegrationTest
+  setup do
+    @communication_website_page = communication_website_pages(:one)
+  end
+
+  test "should get index" do
+    get communication_website_pages_url
+    assert_response :success
+  end
+
+  test "should get new" do
+    get new_communication_website_page_url
+    assert_response :success
+  end
+
+  test "should create communication_website_page" do
+    assert_difference('Communication::Website::Page.count') do
+      post communication_website_pages_url, params: { communication_website_page: { about_id: @communication_website_page.about_id, communication_website_id: @communication_website_page.communication_website_id, description: @communication_website_page.description, kind: @communication_website_page.kind, title: @communication_website_page.title, university_id: @communication_website_page.university_id } }
+    end
+
+    assert_redirected_to communication_website_page_url(Communication::Website::Page.last)
+  end
+
+  test "should show communication_website_page" do
+    get communication_website_page_url(@communication_website_page)
+    assert_response :success
+  end
+
+  test "should get edit" do
+    get edit_communication_website_page_url(@communication_website_page)
+    assert_response :success
+  end
+
+  test "should update communication_website_page" do
+    patch communication_website_page_url(@communication_website_page), params: { communication_website_page: { about_id: @communication_website_page.about_id, communication_website_id: @communication_website_page.communication_website_id, description: @communication_website_page.description, kind: @communication_website_page.kind, title: @communication_website_page.title, university_id: @communication_website_page.university_id } }
+    assert_redirected_to communication_website_page_url(@communication_website_page)
+  end
+
+  test "should destroy communication_website_page" do
+    assert_difference('Communication::Website::Page.count', -1) do
+      delete communication_website_page_url(@communication_website_page)
+    end
+
+    assert_redirected_to communication_website_pages_url
+  end
+end
diff --git a/test/fixtures/communication/website/pages.yml b/test/fixtures/communication/website/pages.yml
new file mode 100644
index 000000000..269ae82dc
--- /dev/null
+++ b/test/fixtures/communication/website/pages.yml
@@ -0,0 +1,48 @@
+# == Schema Information
+#
+# Table name: communication_website_pages
+#
+#  id                       :uuid             not null, primary key
+#  about_type               :string
+#  description              :text
+#  path                     :text
+#  position                 :integer          default(0), not null
+#  published_at             :datetime
+#  slug                     :string
+#  title                    :string
+#  created_at               :datetime         not null
+#  updated_at               :datetime         not null
+#  about_id                 :uuid
+#  communication_website_id :uuid             not null
+#  parent_id                :uuid
+#  university_id            :uuid             not null
+#
+# Indexes
+#
+#  index_communication_website_pages_on_about                     (about_type,about_id)
+#  index_communication_website_pages_on_communication_website_id  (communication_website_id)
+#  index_communication_website_pages_on_parent_id                 (parent_id)
+#  index_communication_website_pages_on_university_id             (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (communication_website_id => communication_websites.id)
+#  fk_rails_...  (parent_id => communication_website_pages.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+
+one:
+  university: one
+  communication_website: one
+  title: MyString
+  description: MyText
+  kind: 1
+  about: one
+
+two:
+  university: two
+  communication_website: two
+  title: MyString
+  description: MyText
+  kind: 1
+  about: two
diff --git a/test/models/communication/website/page_test.rb b/test/models/communication/website/page_test.rb
new file mode 100644
index 000000000..3a6e4fc02
--- /dev/null
+++ b/test/models/communication/website/page_test.rb
@@ -0,0 +1,39 @@
+# == Schema Information
+#
+# Table name: communication_website_pages
+#
+#  id                       :uuid             not null, primary key
+#  about_type               :string
+#  description              :text
+#  path                     :text
+#  position                 :integer          default(0), not null
+#  published_at             :datetime
+#  slug                     :string
+#  title                    :string
+#  created_at               :datetime         not null
+#  updated_at               :datetime         not null
+#  about_id                 :uuid
+#  communication_website_id :uuid             not null
+#  parent_id                :uuid
+#  university_id            :uuid             not null
+#
+# Indexes
+#
+#  index_communication_website_pages_on_about                     (about_type,about_id)
+#  index_communication_website_pages_on_communication_website_id  (communication_website_id)
+#  index_communication_website_pages_on_parent_id                 (parent_id)
+#  index_communication_website_pages_on_university_id             (university_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (communication_website_id => communication_websites.id)
+#  fk_rails_...  (parent_id => communication_website_pages.id)
+#  fk_rails_...  (university_id => universities.id)
+#
+require "test_helper"
+
+class Communication::Website::PageTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/system/communication/website/pages_test.rb b/test/system/communication/website/pages_test.rb
new file mode 100644
index 000000000..8d302d5a5
--- /dev/null
+++ b/test/system/communication/website/pages_test.rb
@@ -0,0 +1,53 @@
+require "application_system_test_case"
+
+class Communication::Website::PagesTest < ApplicationSystemTestCase
+  setup do
+    @communication_website_page = communication_website_pages(:one)
+  end
+
+  test "visiting the index" do
+    visit communication_website_pages_url
+    assert_selector "h1", text: "Communication/Website/Pages"
+  end
+
+  test "creating a Page" do
+    visit communication_website_pages_url
+    click_on "New Communication/Website/Page"
+
+    fill_in "About", with: @communication_website_page.about_id
+    fill_in "Communication website", with: @communication_website_page.communication_website_id
+    fill_in "Description", with: @communication_website_page.description
+    fill_in "Kind", with: @communication_website_page.kind
+    fill_in "Title", with: @communication_website_page.title
+    fill_in "University", with: @communication_website_page.university_id
+    click_on "Create Page"
+
+    assert_text "Page was successfully created"
+    click_on "Back"
+  end
+
+  test "updating a Page" do
+    visit communication_website_pages_url
+    click_on "Edit", match: :first
+
+    fill_in "About", with: @communication_website_page.about_id
+    fill_in "Communication website", with: @communication_website_page.communication_website_id
+    fill_in "Description", with: @communication_website_page.description
+    fill_in "Kind", with: @communication_website_page.kind
+    fill_in "Title", with: @communication_website_page.title
+    fill_in "University", with: @communication_website_page.university_id
+    click_on "Update Page"
+
+    assert_text "Page was successfully updated"
+    click_on "Back"
+  end
+
+  test "destroying a Page" do
+    visit communication_website_pages_url
+    page.accept_confirm do
+      click_on "Destroy", match: :first
+    end
+
+    assert_text "Page was successfully destroyed"
+  end
+end
-- 
GitLab