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 0000000000000000000000000000000000000000..bc230a8e6ce743c1b51058bc67c2828879144cd0 --- /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 0000000000000000000000000000000000000000..b644a3d90f7dfd92d52cee971d90593dcebb2f30 --- /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 0000000000000000000000000000000000000000..5d25e0de67170e0ffc99c4f12935f71fb9a13ee7 --- /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 a4a109b385ffb4c4ae048a8210f4f5810af8c138..0000000000000000000000000000000000000000 --- 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 b28df3e5482be9f58caba4f4039fdb79d0cffb00..18f308ca146ef8f69774953d474401af759862c3 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 0000000000000000000000000000000000000000..ae795453d3ff0c46ccc769dde80f77cd4b8fc877 --- /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 0000000000000000000000000000000000000000..687ca8ffd316e90b660576524967962ff9fd601e --- /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 0000000000000000000000000000000000000000..a2efa068b2ce5c8e9233cca095dc2f82317c2456 --- /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 0000000000000000000000000000000000000000..e79bb8f912ebdcd57dda877fa38050346ff78447 --- /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 0000000000000000000000000000000000000000..4817c4565fdba6c1fb85315820e461ccf4cacf38 --- /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 0000000000000000000000000000000000000000..eaa1bd9f1199c3bd5d9beb4e74b092068aac2964 --- /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 b66259e58818b52a86e235007959567c584c2664..0000000000000000000000000000000000000000 --- 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 5c8a9d022c369aa3638644030572efd93c11cd27..9fbf772c39683fc9aadc303a10b283e329d5dc21 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 4eec47e61a8523bcb2c4496aae0c406021e180b5..0000000000000000000000000000000000000000 --- 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 6a007fa0bc3b70db6df4bfe7cda8c83c51f3df36..7b965af6fee17c8d0ecb7578b331cf2a49bb99ee 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 4073c7237cdbb81ae86b1d01b2e92d97c7a5cfb6..0000000000000000000000000000000000000000 --- 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 7d57755126a6623d0af9d66daa8bf07c9719599a..0000000000000000000000000000000000000000 --- 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 15edaff7d7a66bd4b8951e342e00ce661ad22b2c..0000000000000000000000000000000000000000 --- 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 8053e7aed06e84c537d79ef7fae31ffaf8b13d08..0000000000000000000000000000000000000000 --- 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 9b20654a61bef23b2f64dd9f9c8c3eaa95d2f9ef..0000000000000000000000000000000000000000 --- 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 93258cd65becfc42171f90f8c50ba204ee902f8d..0000000000000000000000000000000000000000 --- 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 c8b159aca6bd32b0ab8312bae06054b3a08954e0..0000000000000000000000000000000000000000 --- 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 a6642dbdf2e9aef4a6ab112bb3d204e28af84a49..0000000000000000000000000000000000000000 --- 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 98788dadd461b86c6309b715d1d4afe8865b28bb..0000000000000000000000000000000000000000 --- 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 ff40bb96078d4cee51910b58ad7a255f98e3f1da..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..76353d73cf41c3b844d27107ab9829c7461829a6 --- /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 0000000000000000000000000000000000000000..d3ac7cc092280b54d6403d6db604ff3a03ccd20b --- /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 0000000000000000000000000000000000000000..1f1ff9a1a99f82c4e67d66577f1ecefe2d33699f --- /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 0000000000000000000000000000000000000000..0a4c0bc99fa4df5837765dc998d1ef07febfda2e --- /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 0000000000000000000000000000000000000000..56fa105a1677cae225cafe1ccca833875e00e707 --- /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 ff41a9f2af841990205a041277dfddab521d690c..0000000000000000000000000000000000000000 --- 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 4ce8c0e76128d8003e482e4e4060d3a5efc939b9..0000000000000000000000000000000000000000 --- 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 40e26f1fc94a40153d4d05873996596999a2c814..0000000000000000000000000000000000000000 --- 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 8e8f80906d5eb50922057197981bbc1b318269f9..0000000000000000000000000000000000000000 --- 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 0794afbe5d507af788f6725997a155b1a2980d0c..0000000000000000000000000000000000000000 --- 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 8739db54925bf2aad299d7f6feb7df9179d33c2d..0000000000000000000000000000000000000000 --- 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 845c56237c19e2a9dc7cf8969efefe7ef5c6ea10..0000000000000000000000000000000000000000 --- 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 a0f8a96f0223436dce7da83bb456ee2087fdce05..0000000000000000000000000000000000000000 --- 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 6723461de7c2a8ed5ff4ac567a1513bb1093cec8..0000000000000000000000000000000000000000 --- 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 d7da0c822b752a2dfd369b3cc7a53f6466931206..0000000000000000000000000000000000000000 --- 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index c9816c4c895b0c66320d86ea4d581599db30fa26..474e8cd1c45b71c1ce95a90ee1509b2bbe29f318 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 64f30c95ca252c12485d6bfe9426351d2c9da82f..a77f1b43c3fa966df6cc89e422e2a46642dd290d 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 2d2dfc63f7e6b28931d063ea3582b3da96b34944..2568a32658cec2be3037135d97d46121decde9b4 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 8e4cafcbfeecfcef4f0887553ed19370fd5bf49a..8cb89f645979e2071d90dee9d44117f98457f6d0 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 245491d6b241e23eaa881d2eb946c709de1a41a4..ff0e30c2ff3a121fb19a3c81c2248dafed8d6992 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 0000000000000000000000000000000000000000..322f38f503c3b7d2b16c8e59e1fc7914382376b9 --- /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 26acb79acdf44e254115057ed2cc058625305402..375624afea4e61cbed006a1adafad11aeabaa406 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 0000000000000000000000000000000000000000..ddd048ecc9f83c919479875e94ad74d6bfbc8b4c --- /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 0000000000000000000000000000000000000000..269ae82dc1339bc2e4e57282d6fef5987e7a20f3 --- /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 0000000000000000000000000000000000000000..3a6e4fc029482c5d0411c81a8742a9bb9d1348f2 --- /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 0000000000000000000000000000000000000000..8d302d5a5e0a47023c138301bef9dab9afd70173 --- /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