From 43fc7fd20c49f4ee0c66013bcb3dc86ad18ddb26 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Tue, 3 Jan 2023 15:01:57 +0100 Subject: [PATCH] single table inheritance --- app/models/communication/website/page.rb | 2 + .../website/page/accessibility.rb | 44 ++++++++++++++++++ .../website/page/administrators.rb | 44 ++++++++++++++++++ .../communication/website/page/authors.rb | 44 ++++++++++++++++++ .../website/page/communication_posts.rb | 45 +++++++++++++++++- .../website/page/education_diplomas.rb | 44 ++++++++++++++++++ .../website/page/education_programs.rb | 44 ++++++++++++++++++ app/models/communication/website/page/home.rb | 46 ++++++++++++++++++- .../communication/website/page/legal_term.rb | 44 ++++++++++++++++++ .../website/page/organizations.rb | 44 ++++++++++++++++++ .../communication/website/page/persons.rb | 44 ++++++++++++++++++ .../website/page/privacy_policy.rb | 44 ++++++++++++++++++ .../website/page/research_papers.rb | 44 ++++++++++++++++++ .../website/page/research_volumes.rb | 44 ++++++++++++++++++ .../communication/website/page/researchers.rb | 44 ++++++++++++++++++ .../communication/website/page/sitemap.rb | 44 ++++++++++++++++++ .../communication/website/page/teachers.rb | 44 ++++++++++++++++++ .../website/page/{special.rb => with_type.rb} | 6 ++- app/models/university/organization.rb | 41 +++++++++-------- app/services/blocks_migration.rb | 29 ------------ ...add_type_to_communication_website_pages.rb | 5 ++ db/schema.rb | 4 +- lib/tasks/app.rake | 4 +- test/fixtures/university/organizations.yml | 41 +++++++++-------- test/models/university/organization_test.rb | 41 +++++++++-------- 25 files changed, 783 insertions(+), 97 deletions(-) create mode 100644 app/models/communication/website/page/accessibility.rb create mode 100644 app/models/communication/website/page/administrators.rb create mode 100644 app/models/communication/website/page/authors.rb create mode 100644 app/models/communication/website/page/education_diplomas.rb create mode 100644 app/models/communication/website/page/education_programs.rb create mode 100644 app/models/communication/website/page/legal_term.rb create mode 100644 app/models/communication/website/page/organizations.rb create mode 100644 app/models/communication/website/page/persons.rb create mode 100644 app/models/communication/website/page/privacy_policy.rb create mode 100644 app/models/communication/website/page/research_papers.rb create mode 100644 app/models/communication/website/page/research_volumes.rb create mode 100644 app/models/communication/website/page/researchers.rb create mode 100644 app/models/communication/website/page/sitemap.rb create mode 100644 app/models/communication/website/page/teachers.rb rename app/models/communication/website/page/{special.rb => with_type.rb} (66%) delete mode 100644 app/services/blocks_migration.rb create mode 100644 db/migrate/20230103132305_add_type_to_communication_website_pages.rb diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 2df26c81e..ed3728c73 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -18,6 +18,7 @@ # slug :string # text :text # title :string +# type :string # created_at :datetime not null # updated_at :datetime not null # communication_website_id :uuid not null, indexed @@ -54,6 +55,7 @@ class Communication::Website::Page < ApplicationRecord include WithPosition include WithTree include WithPath + include WithType include WithPermalink has_summernote :text diff --git a/app/models/communication/website/page/accessibility.rb b/app/models/communication/website/page/accessibility.rb new file mode 100644 index 000000000..f4837f53a --- /dev/null +++ b/app/models/communication/website/page/accessibility.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Accessibility < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/administrators.rb b/app/models/communication/website/page/administrators.rb new file mode 100644 index 000000000..e52736db5 --- /dev/null +++ b/app/models/communication/website/page/administrators.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Administrators < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/authors.rb b/app/models/communication/website/page/authors.rb new file mode 100644 index 000000000..24c5e7aee --- /dev/null +++ b/app/models/communication/website/page/authors.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Authors < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/communication_posts.rb b/app/models/communication/website/page/communication_posts.rb index 6b81a470a..b3cc671eb 100644 --- a/app/models/communication/website/page/communication_posts.rb +++ b/app/models/communication/website/page/communication_posts.rb @@ -1,4 +1,45 @@ -class Communication::Website::Page::CommunicationPosts < Communication::Website::Page::Special +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::CommunicationPosts < Communication::Website::Page def git_path(website) "#{git_path_content_prefix(website)}posts/_index.html" @@ -12,4 +53,4 @@ class Communication::Website::Page::CommunicationPosts < Communication::Website: website.posts ].flatten end -end \ No newline at end of file +end diff --git a/app/models/communication/website/page/education_diplomas.rb b/app/models/communication/website/page/education_diplomas.rb new file mode 100644 index 000000000..52877ff07 --- /dev/null +++ b/app/models/communication/website/page/education_diplomas.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::EducationDiplomas < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/education_programs.rb b/app/models/communication/website/page/education_programs.rb new file mode 100644 index 000000000..c94991234 --- /dev/null +++ b/app/models/communication/website/page/education_programs.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::EducationPrograms < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/home.rb b/app/models/communication/website/page/home.rb index 14ebb4cc7..b62ff158e 100644 --- a/app/models/communication/website/page/home.rb +++ b/app/models/communication/website/page/home.rb @@ -1,4 +1,46 @@ -class Communication::Website::Page::Home < Communication::Website::Page::Special +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Home < Communication::Website::Page + def git_path(website) "#{git_path_content_prefix(website)}_index.html" end @@ -8,4 +50,4 @@ class Communication::Website::Page::Home < Communication::Website::Page::Special def set_slug self.slug = '' end -end \ No newline at end of file +end diff --git a/app/models/communication/website/page/legal_term.rb b/app/models/communication/website/page/legal_term.rb new file mode 100644 index 000000000..2a9dfeb2a --- /dev/null +++ b/app/models/communication/website/page/legal_term.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::LegalTerm < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/organizations.rb b/app/models/communication/website/page/organizations.rb new file mode 100644 index 000000000..faf79eb67 --- /dev/null +++ b/app/models/communication/website/page/organizations.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Organizations < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/persons.rb b/app/models/communication/website/page/persons.rb new file mode 100644 index 000000000..bc6479fc3 --- /dev/null +++ b/app/models/communication/website/page/persons.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Persons < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/privacy_policy.rb b/app/models/communication/website/page/privacy_policy.rb new file mode 100644 index 000000000..d3fe6738b --- /dev/null +++ b/app/models/communication/website/page/privacy_policy.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::PrivacyPolicy < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/research_papers.rb b/app/models/communication/website/page/research_papers.rb new file mode 100644 index 000000000..c2b9393d3 --- /dev/null +++ b/app/models/communication/website/page/research_papers.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::ResearchPapers < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/research_volumes.rb b/app/models/communication/website/page/research_volumes.rb new file mode 100644 index 000000000..0dc34f594 --- /dev/null +++ b/app/models/communication/website/page/research_volumes.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::ResearchVolumes < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/researchers.rb b/app/models/communication/website/page/researchers.rb new file mode 100644 index 000000000..38d9cb850 --- /dev/null +++ b/app/models/communication/website/page/researchers.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Researchers < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/sitemap.rb b/app/models/communication/website/page/sitemap.rb new file mode 100644 index 000000000..6ffd3d027 --- /dev/null +++ b/app/models/communication/website/page/sitemap.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Sitemap < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/teachers.rb b/app/models/communication/website/page/teachers.rb new file mode 100644 index 000000000..06ec7215e --- /dev/null +++ b/app/models/communication/website/page/teachers.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: communication_website_pages +# +# id :uuid not null, primary key +# bodyclass :string +# breadcrumb_title :string +# description :text +# description_short :text +# featured_image_alt :string +# featured_image_credit :text +# full_width :boolean default(FALSE) +# github_path :text +# header_text :text +# kind :integer +# position :integer default(0), not null +# published :boolean default(FALSE) +# slug :string +# text :text +# title :string +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_website_pages_on_communication_website_id (communication_website_id) +# index_communication_website_pages_on_language_id (language_id) +# index_communication_website_pages_on_parent_id (parent_id) +# index_communication_website_pages_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_1a42003f06 (parent_id => communication_website_pages.id) +# fk_rails_280107c62b (communication_website_id => communication_websites.id) +# fk_rails_d208d15a73 (university_id => universities.id) +# +class Communication::Website::Page::Teachers < Communication::Website::Page + +end diff --git a/app/models/communication/website/page/special.rb b/app/models/communication/website/page/with_type.rb similarity index 66% rename from app/models/communication/website/page/special.rb rename to app/models/communication/website/page/with_type.rb index d5770ee21..e3a30a650 100644 --- a/app/models/communication/website/page/special.rb +++ b/app/models/communication/website/page/with_type.rb @@ -1,4 +1,6 @@ -class Communication::Website::Page::Special < Communication::Website::Page +module Communication::Website::Page::WithType + extend ActiveSupport::Concern + def is_necessary? true end @@ -14,4 +16,4 @@ class Communication::Website::Page::Special < Communication::Website::Page def unpublishable? true end -end +end \ No newline at end of file diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index 31c57551e..e3119d42a 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -2,26 +2,27 @@ # # Table name: university_organizations # -# id :uuid not null, primary key -# active :boolean default(TRUE) -# address :string -# city :string -# country :string -# description :text -# email :string -# kind :integer default("company") -# long_name :string -# name :string -# nic :string -# phone :string -# siren :string -# slug :string -# text :text -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# active :boolean default(TRUE) +# address :string +# city :string +# country :string +# description :text +# description_short :text +# email :string +# kind :integer default("company") +# long_name :string +# name :string +# nic :string +# phone :string +# siren :string +# slug :string +# text :text +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/services/blocks_migration.rb b/app/services/blocks_migration.rb deleted file mode 100644 index e6a7db5bc..000000000 --- a/app/services/blocks_migration.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'communication/block/template/base' -require 'communication/block/template/chapter' - -class BlocksMigration - - def self.cleanup - Communication::Website::Post.find_each do |post| - cleanup_item post - end - Communication::Website::Page.find_each do |page| - cleanup_item page - end - end - - private - - def self.cleanup_item(item) - return if item.text.blank? - return if item.blocks.any? - puts "#{item.university}, #{item.website}, #{item.class.to_s.demodulize}, #{item.id}, #{item}" - # puts item.text.to_html - # return - block = item.blocks.create university: item.university, template_kind: :chapter - data = block.data - data['text'] = item.text.to_html - block.data = data - block.save - end -end diff --git a/db/migrate/20230103132305_add_type_to_communication_website_pages.rb b/db/migrate/20230103132305_add_type_to_communication_website_pages.rb new file mode 100644 index 000000000..d8bc0f87a --- /dev/null +++ b/db/migrate/20230103132305_add_type_to_communication_website_pages.rb @@ -0,0 +1,5 @@ +class AddTypeToCommunicationWebsitePages < ActiveRecord::Migration[7.0] + def change + add_column :communication_website_pages, :type, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index dd8b5176e..f326460b9 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[7.0].define(version: 2022_12_29_103238) do +ActiveRecord::Schema[7.0].define(version: 2023_01_03_132305) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -322,6 +322,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_29_103238) do t.uuid "language_id" t.text "featured_image_credit" t.boolean "full_width", default: false + t.string "type" t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id" t.index ["language_id"], name: "index_communication_website_pages_on_language_id" t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id" @@ -713,6 +714,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_29_103238) do t.string "slug" t.text "text" t.string "nic" + t.text "description_short" t.index ["university_id"], name: "index_university_organizations_on_university_id" end diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake index b3c536e31..fdb5a6a68 100644 --- a/lib/tasks/app.rake +++ b/lib/tasks/app.rake @@ -8,7 +8,9 @@ namespace :app do desc 'Fix things' task fix: :environment do - BlocksMigration.cleanup + Communication::Website::Page.find_each do |page| + page.update_column :type, "::Communication::Website::Page::#{page.kind.to_s.classify}" + end end namespace :websites do diff --git a/test/fixtures/university/organizations.yml b/test/fixtures/university/organizations.yml index e69202206..664399044 100644 --- a/test/fixtures/university/organizations.yml +++ b/test/fixtures/university/organizations.yml @@ -2,26 +2,27 @@ # # Table name: university_organizations # -# id :uuid not null, primary key -# active :boolean default(TRUE) -# address :string -# city :string -# country :string -# description :text -# email :string -# kind :integer default("company") -# long_name :string -# name :string -# nic :string -# phone :string -# siren :string -# slug :string -# text :text -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# active :boolean default(TRUE) +# address :string +# city :string +# country :string +# description :text +# description_short :text +# email :string +# kind :integer default("company") +# long_name :string +# name :string +# nic :string +# phone :string +# siren :string +# slug :string +# text :text +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/models/university/organization_test.rb b/test/models/university/organization_test.rb index a57d401f9..bb3781c18 100644 --- a/test/models/university/organization_test.rb +++ b/test/models/university/organization_test.rb @@ -2,26 +2,27 @@ # # Table name: university_organizations # -# id :uuid not null, primary key -# active :boolean default(TRUE) -# address :string -# city :string -# country :string -# description :text -# email :string -# kind :integer default("company") -# long_name :string -# name :string -# nic :string -# phone :string -# siren :string -# slug :string -# text :text -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# active :boolean default(TRUE) +# address :string +# city :string +# country :string +# description :text +# description_short :text +# email :string +# kind :integer default("company") +# long_name :string +# name :string +# nic :string +# phone :string +# siren :string +# slug :string +# text :text +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed # # Indexes # -- GitLab