Skip to content
Snippets Groups Projects
Commit 43fc7fd2 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

single table inheritance

parent c65cabd3
No related branches found
No related tags found
No related merge requests found
Showing
with 730 additions and 55 deletions
......@@ -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
......
# == 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
# == 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
# == 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
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
# == 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
# == 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
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
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
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
......@@ -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
#
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment