diff --git a/app/controllers/admin/communication/website/authors_controller.rb b/app/controllers/admin/communication/website/authors_controller.rb index 5f71ddf18ec2df02e8bd3511e3686d1f32109739..e4b694f4b31f7b90a8f1b09859b483f4cc6c2fb1 100644 --- a/app/controllers/admin/communication/website/authors_controller.rb +++ b/app/controllers/admin/communication/website/authors_controller.rb @@ -1,13 +1,15 @@ class Admin::Communication::Website::AuthorsController < Admin::Communication::Website::ApplicationController def index - @authors = current_university.people.authors.accessible_by(current_ability).ordered.page(params[:page]) + @authors = @website.authors.accessible_by(current_ability) + .ordered + .page(params[:page]) breadcrumb end def show - @author = current_university.people.authors.accessible_by(current_ability).find(params[:id]) - @posts = @author.communication_website_posts.ordered.page(params[:page]) + @author = @website.authors.accessible_by(current_ability).find(params[:id]) + @posts = @author.communication_website_posts.where(communication_website_id: @website.id).ordered.page(params[:page]) breadcrumb end diff --git a/app/controllers/admin/research/researchers_controller.rb b/app/controllers/admin/research/researchers_controller.rb index c8f7efb73a29e9931e5d95605d7f3fa8b209d8c0..ae994e920900f5c34f7bf2bacded2f7ab28928ea 100644 --- a/app/controllers/admin/research/researchers_controller.rb +++ b/app/controllers/admin/research/researchers_controller.rb @@ -6,7 +6,7 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationContr end def show - @researcher = current_university.people.authors.accessible_by(current_ability).find(params[:id]) + @researcher = current_university.people.researchers.accessible_by(current_ability).find(params[:id]) @articles = @researcher.research_journal_articles.ordered.page(params[:page]) breadcrumb end diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index 31e4032dec4dde87ba6685ff90009dab71bd7e52..bbce1fa39e2a37346724e99ba286dcdb611eb553 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -55,9 +55,9 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro end def person_params - params.require(:university_person) - .permit(:first_name, :last_name, :email, :phone, :biography, :slug, :user_id, - :is_author, :is_researcher, :is_teacher, :is_administration) - .merge(university_id: current_university.id) + params.require(:university_person).permit( + :first_name, :last_name, :email, :phone, :biography, :slug, :user_id, + :is_researcher, :is_teacher, :is_administration + ).merge(university_id: current_university.id) end end diff --git a/app/models/communication/website/imported/author.rb b/app/models/communication/website/imported/author.rb index 79689e42705a185f7c84d6888cdad16ce7b32395..9feb591cba6e3748fc6140d9ad97ac75d34f0b70 100644 --- a/app/models/communication/website/imported/author.rb +++ b/app/models/communication/website/imported/author.rb @@ -57,7 +57,6 @@ class Communication::Website::Imported::Author < ApplicationRecord self.author = University::Person.new university: university self.author.last_name = "Doe" # No title yet self.author.first_name = "John" # No title yet - self.is_author = true self.author.save end puts "Update author #{author.id}" diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb index 2019fd5369476f6002fbf6cc8eff643d60856419..c104183822667f6e0343362c5289bb1e50e5bac4 100644 --- a/app/models/communication/website/with_abouts.rb +++ b/app/models/communication/website/with_abouts.rb @@ -19,6 +19,8 @@ module Communication::Website::WithAbouts foreign_key: :communication_website_id, dependent: :destroy + has_many :authors, -> { distinct }, through: :posts + has_many :categories, class_name: 'Communication::Website::Category', foreign_key: :communication_website_id, @@ -49,7 +51,7 @@ module Communication::Website::WithAbouts def people @people ||= begin - people = posts.collect(&:author) + posts.collect(&:author).compact.map(&:author) + people = authors + authors.compact.map(&:author) if about_school? people += programs.collect(&:university_people_through_teachers).flatten people += programs.collect(&:university_people_through_teachers).flatten.map(&:teacher) diff --git a/app/models/university/person.rb b/app/models/university/person.rb index f9c448947ef9ad0e28dd7a302e4c8deffb37b16d..abd7bb54fd5843dd8863ebd400f788d4f661dbeb 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -6,7 +6,6 @@ # email :string # first_name :string # is_administration :boolean -# is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string @@ -91,7 +90,6 @@ class University::Person < ApplicationRecord scope :ordered, -> { order(:last_name, :first_name) } scope :administration, -> { where(is_administration: true) } - scope :authors, -> { where(is_author: true) } scope :teachers, -> { where(is_teacher: true) } scope :researchers, -> { where(is_researcher: true) } diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index 6b54869f5a42562f71dbeee9ebbce79452da1711..2c16151fbd331d0ec0c4f518c124f68dc436d03a 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -6,7 +6,6 @@ # email :string # first_name :string # is_administration :boolean -# is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index 3353e96cb907c060848f722441145f9847645ba0..be788bef945fd5bb828ae62e5d4c8d2f69ab12a7 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -6,7 +6,6 @@ # email :string # first_name :string # is_administration :boolean -# is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string @@ -37,8 +36,8 @@ class University::Person::Author < University::Person end def for_website?(website) - is_author && communication_website_posts.published - .where(communication_website_id: website&.id) - .any? + communication_website_posts.published + .where(communication_website_id: website&.id) + .any? end end diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 727ee2c3a3f2675f8836a76319960616fcddd3b4..f1b7341ad36fad9dcc90a6d001d2b45ee1eca4ab 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -6,7 +6,6 @@ # email :string # first_name :string # is_administration :boolean -# is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index fe13ebe93208a726472d5c811995f5144634b778..6e5f3a761f1432afede463cc1c9b2b05bd110d7e 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -6,7 +6,6 @@ # email :string # first_name :string # is_administration :boolean -# is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index c96bd6db126780c99ed5ccd4da9cb474fbec37ae..99427bb40bfaa74d47f3da9e403dd2991452cd5a 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -38,7 +38,7 @@ <%= f.input :published %> <%= f.input :published_at, html5: true %> <%= f.input :pinned %> - <%= f.association :author, collection: current_university.people.authors.ordered %> + <%= f.association :author, collection: current_university.people.ordered %> </div> </div> <div class="card flex-fill w-100"> diff --git a/app/views/admin/communication/websites/show/_authors.html.erb b/app/views/admin/communication/websites/show/_authors.html.erb deleted file mode 100644 index 0953a1a4149fcb6a19a65326e92c6f6668d405cc..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/websites/show/_authors.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<div class="card mb-5"> - <div class="card-header"> - <div class="float-end"> - <%= link_to t('create'), - new_admin_communication_website_author_path(website_id: @website), - class: button_classes %> - </div> - <h2 class="card-title"> - <%= link_to admin_communication_website_authors_path(website_id: @website) do %> - <%= t('communication.authors', count: 2) %> - <small> - - - <%= t('communication.website.see_all', number: @website.authors.count) %> - </small> - <% end %> - </h2> - </div> - <%= render 'admin/communication/website/authors/list', authors: @website.authors.ordered.limit(10) %> -</div> diff --git a/app/views/admin/communication/websites/show/_categories.html.erb b/app/views/admin/communication/websites/show/_categories.html.erb deleted file mode 100644 index e4bcfbbf47507f74bc1f7ac75b284477e83d3a9f..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/websites/show/_categories.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<div class="card mb-5"> - <div class="card-header"> - <div class="float-end"> - <%= link_to t('create'), - new_admin_communication_website_category_path(website_id: @website), - class: button_classes if can?(:create, Communication::Website::Category) %> - </div> - <h2 class="card-title"> - <%= link_to admin_communication_website_categories_path(website_id: @website) do %> - <%= Communication::Website::Category.model_name.human(count: 2) %> - <small> - - - <%= t('communication.website.see_all', number: @website.categories.count) %> - </small> - <% end %> - </h2> - </div> - <%= render 'admin/communication/website/categories/list', categories: @website.categories.root.ordered %> -</div> diff --git a/app/views/admin/communication/websites/show/_menus.html.erb b/app/views/admin/communication/websites/show/_menus.html.erb deleted file mode 100644 index c5bec2217bc91238ea756b36d1a6d43fafb3c577..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/websites/show/_menus.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<div class="card mb-5"> - <div class="card-header"> - <div class="float-end"> - <%= link_to t('create'), - new_admin_communication_website_menu_path(website_id: @website), - class: button_classes if can?(:create, Communication::Website::Menu) %> - </div> - <h2 class="card-title"> - <%= link_to admin_communication_website_menus_path(website_id: @website) do %> - <%= Communication::Website::Menu.model_name.human(count: 2) %> - <small> - - - <%= t('communication.website.see_all', number: @website.menus.count) %> - </small> - <% end %> - </h2> - </div> - <%= render 'admin/communication/website/menus/list', menus: @website.menus.ordered %> -</div> diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb index 2a083df900647ebd38e6466161293e952aea19bb..2881ea5b68b221cbcec298240bc81c2ab807d789 100644 --- a/app/views/admin/university/people/_form.html.erb +++ b/app/views/admin/university/people/_form.html.erb @@ -46,7 +46,6 @@ <h5 class="card-title mb-0"><%= University::Person.human_attribute_name('abilities') %></h5> </div> <div class="card-body"> - <%= f.input :is_author %> <%= f.input :is_teacher %> <%= f.input :is_researcher %> <%= f.input :is_administration %> diff --git a/db/migrate/20220112085221_remove_is_author_from_university_people.rb b/db/migrate/20220112085221_remove_is_author_from_university_people.rb new file mode 100644 index 0000000000000000000000000000000000000000..96b1d644e5d319106c952ecc6a7945383e506bbb --- /dev/null +++ b/db/migrate/20220112085221_remove_is_author_from_university_people.rb @@ -0,0 +1,5 @@ +class RemoveIsAuthorFromUniversityPeople < ActiveRecord::Migration[6.1] + def change + remove_column :university_people, :is_author, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 50acbfe29f7e1b4ed1b69405fdc0f7c13a207d46..44cbf87b63419edbf53d97ac4f855275e7f098b5 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_01_11_101410) do +ActiveRecord::Schema.define(version: 2022_01_12_085221) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -515,7 +515,6 @@ ActiveRecord::Schema.define(version: 2022_01_11_101410) do t.string "last_name" t.string "first_name" t.string "slug" - t.boolean "is_author" t.boolean "is_researcher" t.boolean "is_teacher" t.boolean "is_administration"