diff --git a/app/models/communication/website/home.rb b/app/models/communication/website/home.rb index 10ea338834a21df1afd149ff6a6aa291d5efa6e4..3b55fc80c9ff3594106df7e9f763d1f82de5ef9c 100644 --- a/app/models/communication/website/home.rb +++ b/app/models/communication/website/home.rb @@ -6,7 +6,7 @@ # description :text # featured_image_alt :string # github_path :text -# text_new :text +# text :text # created_at :datetime not null # updated_at :datetime not null # communication_website_id :uuid not null, indexed @@ -30,8 +30,7 @@ class Communication::Website::Home < ApplicationRecord belongs_to :university belongs_to :website, foreign_key: :communication_website_id - has_rich_text :text - has_summernote :text_new + has_summernote :text def to_s website.to_s diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 51d29b9f1707908f1a652819f649af200fe399ae..19787f39c8f03e934dc72847934a102f786debe8 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -12,7 +12,7 @@ # position :integer default(0), not null # published :boolean default(FALSE) # slug :string -# text_new :text +# text :text # title :string # created_at :datetime not null # updated_at :datetime not null @@ -48,8 +48,7 @@ class Communication::Website::Page < ApplicationRecord include WithPosition include WithBlocks - has_rich_text :text - has_summernote :text_new + has_summernote :text belongs_to :university belongs_to :website, diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 9a9033fbe5d8b1c8b10882a1dc7ff128209dad58..21ab6e532c964bcbdce31606436b1f8a32fd2b11 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -11,7 +11,7 @@ # published :boolean default(FALSE) # published_at :datetime # slug :text -# text_new :text +# text :text # title :string # created_at :datetime not null # updated_at :datetime not null @@ -38,8 +38,7 @@ class Communication::Website::Post < ApplicationRecord include WithMenuItemTarget include WithSlug # We override slug_unavailable? method - has_rich_text :text - has_summernote :text_new + has_summernote :text has_one :imported_post, class_name: 'Communication::Website::Imported::Post', diff --git a/app/models/concerns/with_inheritance.rb b/app/models/concerns/with_inheritance.rb index 279fe33899a4e3f516b0cb0011c819feb360e9df..7f7dd625cd2ebe8d9f2f7e7500242fce0f72b047 100644 --- a/app/models/concerns/with_inheritance.rb +++ b/app/models/concerns/with_inheritance.rb @@ -4,8 +4,7 @@ module WithInheritance included do def self.rich_text_areas_with_inheritance(*properties) properties.each do |property| - has_rich_text property - has_summernote :"#{property}_new" + has_summernote property class_eval <<-CODE, __FILE__, __LINE__ + 1 def best_#{property} @@ -15,17 +14,6 @@ module WithInheritance def best_#{property}_source best_source("#{property}") end - - def best_#{property}_new - value = send("#{property}_new") - value.blank? ? parent&.best_#{property}_new : value - end - - def best_#{property}_new_source(is_ancestor: false) - value = send("#{property}_new") - return (is_ancestor ? self : nil) if value.present? - parent&.best_#{property}_new_source(is_ancestor: true) - end CODE end end @@ -38,9 +26,9 @@ module WithInheritance value.blank? ? parent&.send("best_#{property}") : value end - def best_source(property) + def best_source(property, is_ancestor: false) value = send(property) - return nil if !value.blank? # There is a value, no inheritance needed - best(property)&.record + return (is_ancestor ? self : nil) if value.present? + parent&.send(:best_source, property, is_ancestor: true) end end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index a30ad88fa6b2e4bbe46db01c72959ddd3e40b238..cec653a4a5952ba56db12f73f460b52a52e3a8b6 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -3,29 +3,29 @@ # Table name: education_programs # # id :uuid not null, primary key -# accessibility_new :text +# accessibility :text # capacity :integer -# contacts_new :text -# content_new :text +# contacts :text +# content :text # continuing :boolean # description :text -# duration_new :text +# duration :text # ects :integer -# evaluation_new :text +# evaluation :text # featured_image_alt :string # level :integer # name :string -# objectives_new :text -# opportunities_new :text -# other_new :text +# objectives :text +# opportunities :text +# other :text # path :string -# pedagogy_new :text +# pedagogy :text # position :integer default(0) -# prerequisites_new :text -# pricing_new :text +# prerequisites :text +# pricing :text # published :boolean default(FALSE) -# registration_new :text -# results_new :text +# registration :text +# results :text # slug :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index cb9bf3f7fdaf15d41111f524f2082f6a46b1922f..18e2717aebcda7a9b9bd8f3a5dcf3c5aa3d8fc76 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -10,7 +10,7 @@ # published_at :datetime # references :text # slug :string -# text_new :text +# text :text # title :string # created_at :datetime not null # updated_at :datetime not null @@ -38,8 +38,7 @@ class Research::Journal::Article < ApplicationRecord include WithBlobs include WithPosition - has_rich_text :text - has_summernote :text_new + has_summernote :text has_one_attached :pdf belongs_to :university diff --git a/app/models/research/laboratory/axis.rb b/app/models/research/laboratory/axis.rb index 414cef8235ec765c60c6d44659f00f160e3a824f..11e2f3d15423984867cb20a04840df99da6014b4 100644 --- a/app/models/research/laboratory/axis.rb +++ b/app/models/research/laboratory/axis.rb @@ -7,7 +7,7 @@ # name :string # position :integer # short_name :string -# text_new :text +# text :text # created_at :datetime not null # updated_at :datetime not null # research_laboratory_id :uuid not null, indexed @@ -26,8 +26,7 @@ class Research::Laboratory::Axis < ApplicationRecord include WithPosition - has_rich_text :text - has_summernote :text_new + has_summernote :text belongs_to :university belongs_to :laboratory, foreign_key: :research_laboratory_id diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 5964bd039e989474744e441c1f369b627e984786..32ff3e587089386e7a03034a4bbf4109d5bb78ba 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -3,7 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key -# biography_new :text +# biography :text # description :text # email :string # first_name :string @@ -37,8 +37,7 @@ class University::Person < ApplicationRecord include WithPicture include WithEducation - has_rich_text :biography - has_summernote :biography_new + has_summernote :biography belongs_to :university belongs_to :user, optional: true diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index 45c0cf4c7c389a6029fadf3018d75465cccc01b2..b7bca44426417b0705317eb94dbdb4af47d11eeb 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -3,7 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key -# biography_new :text +# biography :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index 1bb44c1eb9111e6857654761c402c169e7b2db21..5bf2ee2c4a68b86044a237691a08fd9b4391e150 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -3,7 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key -# biography_new :text +# biography :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 207a0919a838b9554625946d10b22f74952b33e1..9ca52242568e5da3fee487a5a4868d3bb28aaa88 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -3,7 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key -# biography_new :text +# biography :text # description :text # email :string # first_name :string diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index 18518ba9231e6231cbe06d3b9aa4b3b96f6cce7d..2f75bd1ab96b16846fa83af4670c2724d9d116e4 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -3,7 +3,7 @@ # Table name: university_people # # id :uuid not null, primary key -# biography_new :text +# biography :text # description :text # email :string # first_name :string diff --git a/app/views/admin/communication/website/homes/edit.html.erb b/app/views/admin/communication/website/homes/edit.html.erb index ca117a77ceb0e53e27cad5d07d7341cbf1a1118c..5f6ed054c1e30e6f8fe53b2c47c0be9cdd03fe0a 100644 --- a/app/views/admin/communication/website/homes/edit.html.erb +++ b/app/views/admin/communication/website/homes/edit.html.erb @@ -10,7 +10,7 @@ </div> <div class="card-body"> <%= f.input :description %> - <%= f.input :text, as: :rich_text_area %> + <%= f.input :text, as: :summernote %> </div> </div> </div> diff --git a/app/views/admin/communication/website/pages/_form.html.erb b/app/views/admin/communication/website/pages/_form.html.erb index b7b890ce605ac69d123db269a8cbd3cf9096b4ab..2781e1729e265ea7e183b6cd7815823ffd3f4f6d 100644 --- a/app/views/admin/communication/website/pages/_form.html.erb +++ b/app/views/admin/communication/website/pages/_form.html.erb @@ -8,7 +8,7 @@ <div class="card-body"> <%= f.input :title %> <%= f.input :description %> - <%= f.input :text, as: :rich_text_area %> + <%= f.input :text, as: :summernote %> <%= f.association :related_category, collection: collection_tree(@website.categories), label_method: ->(p) { sanitize p[:label] }, diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index 99427bb40bfaa74d47f3da9e403dd2991452cd5a..c82cdb4b22eecf8375735497c3deb1abaee4c3e8 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -8,7 +8,7 @@ <div class="card-body"> <%= f.input :title %> <%= f.input :description %> - <%= f.input :text, as: :rich_text_area %> + <%= f.input :text, as: :summernote %> </div> </div> <div class="card flex-fill w-100"> diff --git a/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb b/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb index 50abd4dd0ce3ec6de5d3cab6ef1e4273e9e7c887..2fd2b5fcd8a60009a89f0356886a602af9b106e5 100644 --- a/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb +++ b/app/views/admin/education/programs/forms/_input_with_inheritance.html.erb @@ -17,7 +17,7 @@ id = "#{property}Collapse" </a> </div> <div class="collapse" id="<%= id %>"> - <%= f.input property, as: :rich_text_area, label: false %> + <%= f.input property, as: :summernote, label: false %> <div class="bg-light p-2 mt-n2"> <b><%= t 'admin.inheritance.sentence_html', link: link_to(best_prop_source, [:admin, best_prop_source]) %></b><br> <%= best_prop_value %> @@ -25,5 +25,5 @@ id = "#{property}Collapse" </div> </div> <% else %> - <%= f.input property, as: :rich_text_area %> + <%= f.input property, as: :summernote %> <% end %> diff --git a/app/views/admin/research/journal/articles/_form.html.erb b/app/views/admin/research/journal/articles/_form.html.erb index 46bf970021c39cf8cd58f8a335d3ecf844493a28..dfb583c60d1d172b5887ce56b207c98bab37fdd1 100644 --- a/app/views/admin/research/journal/articles/_form.html.erb +++ b/app/views/admin/research/journal/articles/_form.html.erb @@ -15,7 +15,7 @@ } %> <%= f.input :abstract, as: :text, input_html: { rows: 8 } %> <%= f.input :pdf %> - <%= f.input :text, as: :rich_text_area %> + <%= f.input :text, as: :summernote %> <%= f.input :references, as: :text, input_html: { rows: 10 } %> </div> </div> diff --git a/app/views/admin/research/laboratory/axes/_form.html.erb b/app/views/admin/research/laboratory/axes/_form.html.erb index 1528df4da672855163b999b25c7910f1df404dc9..f0476a1520b10dfe1c6f4dc62d81abfbced3fdd8 100644 --- a/app/views/admin/research/laboratory/axes/_form.html.erb +++ b/app/views/admin/research/laboratory/axes/_form.html.erb @@ -15,7 +15,7 @@ </div> </div> <%= f.input :description, as: :text, input_html: { rows: 2 } %> - <%= f.input :text, as: :rich_text_area %> + <%= f.input :text, as: :summernote %> </div> </div> </div> diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb index e5781875d4a45d3464ac0ed617a9cde8c15647b2..57edd82edd6633166a7c0773e33699950ef0d237 100644 --- a/app/views/admin/university/people/_form.html.erb +++ b/app/views/admin/university/people/_form.html.erb @@ -23,7 +23,7 @@ </div> </div> <%= f.input :description %> - <%= f.input :biography, as: :rich_text_area %> + <%= f.input :biography, as: :summernote %> </div> </div> <div class="card flex-fill w-100"> diff --git a/db/migrate/20220215142845_rename_new_texts.rb b/db/migrate/20220215142845_rename_new_texts.rb new file mode 100644 index 0000000000000000000000000000000000000000..165437ba0c576a6ab94ecceeb299ff6940d82307 --- /dev/null +++ b/db/migrate/20220215142845_rename_new_texts.rb @@ -0,0 +1,23 @@ +class RenameNewTexts < ActiveRecord::Migration[6.1] + def change + rename_column :communication_website_homes, :text_new, :text + rename_column :communication_website_pages, :text_new, :text + rename_column :communication_website_posts, :text_new, :text + rename_column :research_journal_articles, :text_new, :text + rename_column :research_laboratory_axes, :text_new, :text + rename_column :university_people, :biography_new, :biography + rename_column :education_programs, :accessibility_new, :accessibility + rename_column :education_programs, :contacts_new, :contacts + rename_column :education_programs, :duration_new, :duration + rename_column :education_programs, :evaluation_new, :evaluation + rename_column :education_programs, :objectives_new, :objectives + rename_column :education_programs, :opportunities_new, :opportunities + rename_column :education_programs, :other_new, :other + rename_column :education_programs, :pedagogy_new, :pedagogy + rename_column :education_programs, :prerequisites_new, :prerequisites + rename_column :education_programs, :pricing_new, :pricing + rename_column :education_programs, :registration_new, :registration + rename_column :education_programs, :content_new, :content + rename_column :education_programs, :results_new, :results + end +end diff --git a/db/schema.rb b/db/schema.rb index 11b72faae612a55bbf551356fe5ab41f0a683f07..6afe5bdb942d0fe14d253a1352583e38948a3bc3 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: 2022_02_15_094808) do +ActiveRecord::Schema.define(version: 2022_02_15_142845) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -141,7 +141,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.text "github_path" t.string "featured_image_alt" t.text "description" - t.text "text_new" + t.text "text" t.index ["communication_website_id"], name: "idx_comm_website_homes_on_communication_website_id" t.index ["university_id"], name: "index_communication_website_homes_on_university_id" end @@ -304,7 +304,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.text "github_path" t.uuid "related_category_id" t.string "featured_image_alt" - t.text "text_new" + t.text "text" 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" @@ -327,7 +327,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.uuid "author_id" t.boolean "pinned", default: false t.string "featured_image_alt" - t.text "text_new" + t.text "text" t.index ["author_id"], name: "index_communication_website_posts_on_author_id" t.index ["communication_website_id"], name: "index_communication_website_posts_on_communication_website_id" t.index ["university_id"], name: "index_communication_website_posts_on_university_id" @@ -424,19 +424,19 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.text "description" t.boolean "published", default: false t.string "featured_image_alt" - t.text "accessibility_new" - t.text "contacts_new" - t.text "duration_new" - t.text "evaluation_new" - t.text "objectives_new" - t.text "opportunities_new" - t.text "other_new" - t.text "pedagogy_new" - t.text "prerequisites_new" - t.text "pricing_new" - t.text "registration_new" - t.text "content_new" - t.text "results_new" + t.text "accessibility" + t.text "contacts" + t.text "duration" + t.text "evaluation" + t.text "objectives" + t.text "opportunities" + t.text "other" + t.text "pedagogy" + t.text "prerequisites" + t.text "pricing" + t.text "registration" + t.text "content" + t.text "results" t.index ["parent_id"], name: "index_education_programs_on_parent_id" t.index ["university_id"], name: "index_education_programs_on_university_id" end @@ -491,7 +491,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.string "slug" t.boolean "published", default: false t.integer "position" - t.text "text_new" + t.text "text" t.index ["research_journal_id"], name: "index_research_journal_articles_on_research_journal_id" t.index ["research_journal_volume_id"], name: "index_research_journal_articles_on_research_journal_volume_id" t.index ["university_id"], name: "index_research_journal_articles_on_university_id" @@ -555,7 +555,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "short_name" - t.text "text_new" + t.text "text" t.index ["research_laboratory_id"], name: "index_research_laboratory_axes_on_research_laboratory_id" t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end @@ -609,7 +609,7 @@ ActiveRecord::Schema.define(version: 2022_02_15_094808) do t.text "description" t.boolean "habilitation", default: false t.boolean "tenure", default: false - t.text "biography_new" + t.text "biography" t.index ["university_id"], name: "index_university_people_on_university_id" t.index ["user_id"], name: "index_university_people_on_user_id" end