diff --git a/app/controllers/admin/administration/members_controller.rb b/app/controllers/admin/administration/members_controller.rb index fb2384cad42f738c5bbd370eacb4073d9b0e5246..b683ef4b2dbb3f940a576022c6b3e4172a9b433c 100644 --- a/app/controllers/admin/administration/members_controller.rb +++ b/app/controllers/admin/administration/members_controller.rb @@ -56,7 +56,7 @@ class Admin::Administration::MembersController < Admin::Administration::Applicat def member_params params.require(:administration_member) - .permit(:first_name, :last_name, :biography, :slug, :user_id, + .permit(:first_name, :last_name, :email, :phone, :biography, :slug, :user_id, :is_author, :is_researcher, :is_teacher, :is_administrative) .merge(university_id: current_university.id) end diff --git a/app/controllers/admin/communication/website/authors_controller.rb b/app/controllers/admin/communication/website/authors_controller.rb index 432d5e02dd126dadcb9d2f91fe9b0a6f858384f9..83c09f2d0bfa1bd4640d9d618db1635f137173df 100644 --- a/app/controllers/admin/communication/website/authors_controller.rb +++ b/app/controllers/admin/communication/website/authors_controller.rb @@ -1,68 +1,23 @@ class Admin::Communication::Website::AuthorsController < Admin::Communication::Website::ApplicationController - load_and_authorize_resource class: Communication::Website::Author, through: :website def index - @authors = @website.authors.ordered.page(params[:page]) + @authors = current_university.members.authors.accessible_by(current_ability).ordered.page(params[:page]) breadcrumb end def show - @posts = @author.posts.ordered.page(params[:page]) + @author = current_university.members.authors.accessible_by(current_ability).find(params[:id]) + @posts = @author.communication_website_posts.ordered.page(params[:page]) breadcrumb end - def publish - @author.force_publish! - redirect_to admin_communication_website_author_path(@author), notice: t('admin.will_be_published_html', model: @author.to_s) - end - - def new - @author.website = @website - breadcrumb - end - - def edit - breadcrumb - add_breadcrumb t('edit') - end - - def create - @author.website = @website - if @author.save - redirect_to admin_communication_website_author_path(@author), notice: t('admin.successfully_created_html', model: @author.to_s) - else - breadcrumb - render :new, status: :unprocessable_entity - end - end - - def update - if @author.update(author_params) - redirect_to admin_communication_website_author_path(@author), notice: t('admin.successfully_updated_html', model: @author.to_s) - else - breadcrumb - add_breadcrumb t('edit') - render :edit, status: :unprocessable_entity - end - end - - def destroy - @author.destroy - redirect_to admin_communication_website_authors_url, notice: t('admin.successfully_destroyed_html', model: @author.to_s) - end - protected def breadcrumb super - add_breadcrumb Communication::Website::Author.model_name.human(count: 2), - admin_communication_website_authors_path + add_breadcrumb t('communication.authors', count: 2), + admin_communication_website_authors_path breadcrumb_for @author end - def author_params - params.require(:communication_website_author) - .permit(:website_id, :first_name, :last_name, :biography, :slug, :user_id) - .merge(university_id: current_university.id) - end end diff --git a/app/controllers/admin/education/teachers_controller.rb b/app/controllers/admin/education/teachers_controller.rb index 727280efe99638da962cfbf75fb4069a228decd7..aac641dce130181db9445390570842c5b08096d2 100644 --- a/app/controllers/admin/education/teachers_controller.rb +++ b/app/controllers/admin/education/teachers_controller.rb @@ -1,24 +1,14 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationController - load_and_authorize_resource class: Education::Teacher, - through: :current_university, - through_association: :education_teachers + before_action :get_teacher, except: :index def index - @teachers = @teachers.ordered.page(params[:page]) + @teachers = current_university.members.teachers.accessible_by(current_ability).ordered.page(params[:page]) breadcrumb end def show breadcrumb - end - - def publish - @teacher.force_publish! - redirect_to admin_education_teacher_path(@teacher), notice: t('admin.will_be_published_html', model: @teacher.to_s) - end - - def new - breadcrumb + @programs = @teacher.education_programs.ordered.page(params[:page]) end def edit @@ -26,15 +16,6 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationContro add_breadcrumb t('edit') end - def create - if @teacher.save - redirect_to admin_education_teacher_path(@teacher), notice: t('admin.successfully_created_html', model: @teacher.to_s) - else - breadcrumb - render :new, status: :unprocessable_entity - end - end - def update if @teacher.update(teacher_params) redirect_to admin_education_teacher_path(@teacher), notice: t('admin.successfully_updated_html', model: @teacher.to_s) @@ -45,23 +26,21 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationContro end end - def destroy - @teacher.destroy - redirect_to admin_education_teachers_url, notice: t('admin.successfully_destroyed_html', model: @teacher.to_s) - end - protected + def get_teacher + @teacher = current_university.members.teachers.accessible_by(current_ability).find(params[:id]) + end + def breadcrumb super - add_breadcrumb Education::Teacher.model_name.human(count: 2), + add_breadcrumb t('education.teachers', count: 2), admin_education_teachers_path breadcrumb_for @teacher end def teacher_params - params.require(:education_teacher) - .permit(:first_name, :last_name, :biography, :slug, :user_id) - .merge(university_id: current_university.id) + params.require(:administration_member) + .permit(education_program_ids: []) end end diff --git a/app/controllers/admin/research/researchers_controller.rb b/app/controllers/admin/research/researchers_controller.rb index 47253a65106ba598322038fd665ec067cf0d05a0..608248c025a82406a6e0ae0f0977398c1bb37dbe 100644 --- a/app/controllers/admin/research/researchers_controller.rb +++ b/app/controllers/admin/research/researchers_controller.rb @@ -1,61 +1,23 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationController - load_and_authorize_resource class: Research::Researcher, - through: :current_university, - through_association: :research_researchers def index - @researchers = @researchers.ordered.page(params[:page]) + @researchers = current_university.members.researchers.accessible_by(current_ability).ordered.page(params[:page]) breadcrumb end def show + @researcher = current_university.members.authors.accessible_by(current_ability).find(params[:id]) + @articles = @researcher.research_journal_articles.ordered.page(params[:page]) breadcrumb end - def new - breadcrumb - end - - def edit - breadcrumb - add_breadcrumb t('edit') - end - - def create - if @researcher.save - redirect_to [:admin, @researcher], notice: t('admin.successfully_created_html', model: @researcher.to_s) - else - breadcrumb - render :new, status: :unprocessable_entity - end - end - - def update - if @researcher.update(researcher_params) - redirect_to [:admin, @researcher], notice: t('admin.successfully_updated_html', model: @researcher.to_s) - else - breadcrumb - add_breadcrumb t('edit') - render :edit, status: :unprocessable_entity - end - end - - def destroy - @researcher.destroy - redirect_to admin_research_researchers_url, notice: t('admin.successfully_destroyed_html', model: @researcher.to_s) - end - protected def breadcrumb super - add_breadcrumb Research::Researcher.model_name.human(count: 2), admin_research_researchers_path + add_breadcrumb t('researcher.researchers', count: 2), + admin_research_researchers_path breadcrumb_for @researcher end - def researcher_params - params.require(:research_researcher) - .permit(:first_name, :last_name, :slug, :biography, :user_id) - .merge(university_id: current_university.id) - end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 72e77c19270bb9dd909780c1e72033853d5d34b3..2f1e93d76a447b288e7de9f3af06b07dba99138d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -13,6 +13,7 @@ class Ability def visitor can :read, Administration::Qualiopi::Criterion can :read, Administration::Qualiopi::Indicator + can :read, Administration::Member can :read, Communication::Website, university_id: @user.university_id can :read, Communication::Website::Page, university_id: @user.university_id can :read, Communication::Website::Post, university_id: @user.university_id @@ -22,7 +23,6 @@ class Ability can :read, Communication::Website::Imported::Post, university_id: @user.university_id can :read, Education::Program, university_id: @user.university_id can :read, Education::School, university_id: @user.university_id - can :read, Research::Researcher can :read, Research::Journal, university_id: @user.university_id can :read, Research::Journal::Article, university_id: @user.university_id can :read, Research::Journal::Volume, university_id: @user.university_id @@ -32,6 +32,7 @@ class Ability def admin can :read, Administration::Qualiopi::Criterion can :read, Administration::Qualiopi::Indicator + can :manage, Administration::Member can :read, Communication::Website, university_id: @user.university_id can :manage, Communication::Website::Page, university_id: @user.university_id can :manage, Communication::Website::Post, university_id: @user.university_id @@ -43,7 +44,6 @@ class Ability can :manage, Communication::Website::Imported::Page, university_id: @user.university_id can :manage, Communication::Website::Imported::Post, university_id: @user.university_id can :manage, Education::Program, university_id: @user.university_id - can :manage, Research::Researcher can :manage, Research::Journal, university_id: @user.university_id can :manage, Research::Journal::Article, university_id: @user.university_id can :manage, Research::Journal::Volume, university_id: @user.university_id diff --git a/app/models/administration/member.rb b/app/models/administration/member.rb index 4d428784d2d671e455bf93ef2df3a8523b7e7f58..857a248c383762259e883177fbbb7a099648aa78 100644 --- a/app/models/administration/member.rb +++ b/app/models/administration/member.rb @@ -3,12 +3,14 @@ # Table name: administration_members # # id :uuid not null, primary key +# email :string # first_name :string # is_administrative :boolean # is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string +# phone :string # slug :string # created_at :datetime not null # updated_at :datetime not null @@ -34,15 +36,118 @@ class Administration::Member < ApplicationRecord belongs_to :university belongs_to :user, optional: true + has_many :communication_website_posts, + class_name: 'Communication::Website::Post', + foreign_key: :author_id, + dependent: :nullify + + has_and_belongs_to_many :research_journal_articles, + class_name: 'Research::Journal::Article', + join_table: :research_journal_articles_researchers, + foreign_key: :researcher_id + + has_and_belongs_to_many :education_programs, + class_name: 'Education::Program', + join_table: :education_programs_teachers, + foreign_key: :education_teacher_id, + association_foreign_key: :education_program_id + + has_many :communication_websites, + -> { distinct }, + through: :communication_website_posts, + source: :website + has_many :research_websites, + -> { distinct }, + through: :research_journal_articles, + source: :websites + has_many :education_websites, + -> { distinct }, + through: :education_programs, + source: :websites + + validates_presence_of :first_name, :last_name + validates_uniqueness_of :email, scope: :university_id, allow_blank: true, if: :will_save_change_to_email? + validates_format_of :email, with: Devise::email_regexp, allow_blank: true, if: :will_save_change_to_email? + + scope :ordered, -> { order(:last_name, :first_name) } + scope :administratives, -> { where(is_administrative: true) } + scope :authors, -> { where(is_author: true) } + scope :teachers, -> { where(is_teacher: true) } + scope :researchers, -> { where(is_researcher: true) } def to_s "#{last_name} #{first_name}" end def websites - [] - # TODO + Communication::Website.where(id: [ + communication_website_ids, + research_website_ids, + education_website_ids + ].flatten.uniq) + end + + def github_manifest + manifest = [] + manifest.concat(author_github_manifest_items) if is_author? + manifest.concat(researcher_github_manifest_items) if is_researcher? + manifest.concat(teacher_github_manifest_items) if is_teacher? + manifest + end + + def author_github_manifest_items + [ + { + identifier: "author", + generated_path: -> (github_file) { "#{github_file.website.authors_github_directory}/#{slug}.yml" }, + data: -> (github_file) { ApplicationController.render( + template: "admin/communication/website/authors/jekyll", + layout: false, + assigns: { author: self, github_file: github_file } + ) } + }, + { + identifier: "author_collection_item", + generated_path: -> (github_file) { "_data/authors/#{slug}.yml" }, + data: -> (github_file) { ApplicationController.render( + template: "admin/communication/website/authors/jekyll_collection", + formats: [:yml], + layout: false, + assigns: { author: self, github_file: github_file } + ) } + } + ] + end + + def researcher_github_manifest_items + [ + { + identifier: "researcher_collection_item", + generated_path: -> (github_file) { "_data/researchers/#{slug}.yml" }, + data: -> (github_file) { ApplicationController.render( + template: "admin/research/researchers/jekyll_collection", + formats: [:yml], + layout: false, + assigns: { researcher: self, github_file: github_file } + ) } + } + ] + end + + def teacher_github_manifest_items + [ + { + identifier: "teacher_collection_item", + generated_path: -> (github_file) { "_data/teachers/#{slug}.yml" }, + data: -> (github_file) { ApplicationController.render( + template: "admin/education/teachers/jekyll_collection", + formats: [:yml], + layout: false, + assigns: { teacher: self, github_file: github_file } + ) } + } + ] end end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 3c318cbaee870d2c7afdd7337371d6b7a8107b41..2553b6d9debb529c1fdf0e9fbb680f77b9176cbb 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -47,10 +47,6 @@ class Communication::Website < ApplicationRecord class_name: 'Communication::Website::Category', foreign_key: :communication_website_id, dependent: :destroy - has_many :authors, - class_name: 'Communication::Website::Author', - foreign_key: :communication_website_id, - dependent: :destroy has_many :menus, class_name: 'Communication::Website::Menu', foreign_key: :communication_website_id, diff --git a/app/models/communication/website/author.rb b/app/models/communication/website/author.rb deleted file mode 100644 index fe7a41c2c5efffa36a59c899f530f0efb003f204..0000000000000000000000000000000000000000 --- a/app/models/communication/website/author.rb +++ /dev/null @@ -1,76 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_authors -# -# id :uuid not null, primary key -# first_name :string -# github_path :text -# last_name :string -# slug :string -# created_at :datetime not null -# updated_at :datetime not null -# communication_website_id :uuid not null -# university_id :uuid not null -# user_id :uuid -# -# Indexes -# -# idx_comm_website_authors_on_communication_website_id (communication_website_id) -# index_communication_website_authors_on_university_id (university_id) -# index_communication_website_authors_on_user_id (user_id) -# -# Foreign Keys -# -# fk_rails_... (communication_website_id => communication_websites.id) -# fk_rails_... (university_id => universities.id) -# fk_rails_... (user_id => users.id) -# -class Communication::Website::Author < ApplicationRecord - include WithGithubFiles - include WithSlug - - has_rich_text :biography - - has_one :imported_author, - class_name: 'Communication::Website::Imported::Author', - dependent: :destroy - belongs_to :university - belongs_to :user, optional: true - belongs_to :website, - foreign_key: :communication_website_id - has_many :posts, - class_name: 'Communication::Website::Post', - dependent: :nullify - - validates :slug, uniqueness: { scope: :communication_website_id } - - scope :ordered, -> { order(:last_name, :first_name) } - - def to_s - "#{last_name} #{first_name}" - end - - # Override from WithGithubFiles - def github_path_generated - "#{website.authors_github_directory}/#{slug}.html" - end - - def github_manifest - super << { - identifier: "collection_item", - generated_path: -> { "_data/authors/#{slug}.yml" }, - data: -> (github_file) { ApplicationController.render( - template: "admin/communication/website/authors/jekyll_collection", - formats: [:yml], - layout: false, - assigns: { author: self, github_file: github_file } - ) } - } - end - - protected - - def slug_unavailable?(slug) - self.class.unscoped.where(communication_website_id: self.communication_website_id, slug: slug).where.not(id: self.id).exists? - end -end diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 667eca0de09d26b024804b0e393c51f5446bd0fe..1b08ce315648366b4a4b7403b04f86de707a4bda 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -89,7 +89,7 @@ class Communication::Website::Category < ApplicationRecord def github_manifest super << { identifier: "collection_item", - generated_path: -> { "_data/categories/#{slug}.yml" }, + generated_path: -> (github_file) { "_data/categories/#{slug}.yml" }, data: -> (github_file) { ApplicationController.render( template: "admin/communication/website/categories/jekyll_collection", formats: [:yml], diff --git a/app/models/communication/website/github_file.rb b/app/models/communication/website/github_file.rb index 2abf6433c4f041c301ecb85a3d3ca9ea51aa3d7d..00745fe4bea6c4482d52a03f61abf03dd2b14f34 100644 --- a/app/models/communication/website/github_file.rb +++ b/app/models/communication/website/github_file.rb @@ -30,7 +30,7 @@ class Communication::Website::GithubFile < ApplicationRecord return unless valid_for_publication? && github.valid? add_to_batch(github) if github.commit_batch(github_commit_message) - update_column :github_path, manifest_data[:generated_path].call + update_column :github_path, manifest_data[:generated_path].call(self) end end handle_asynchronously :publish, queue: 'default' @@ -82,7 +82,7 @@ class Communication::Website::GithubFile < ApplicationRecord def github_params { - path: manifest_data[:generated_path].call, + path: manifest_data[:generated_path].call(self), previous_path: github_path, data: manifest_data[:data].call(self) } diff --git a/app/models/communication/website/imported/author.rb b/app/models/communication/website/imported/author.rb index d36eb831d985a99e6fa1e342a33cd2f737d6212d..e820c79573c33ae61a2f971aee3ff82309143551 100644 --- a/app/models/communication/website/imported/author.rb +++ b/app/models/communication/website/imported/author.rb @@ -22,7 +22,7 @@ # # Foreign Keys # -# fk_rails_... (author_id => communication_website_authors.id) +# fk_rails_... (author_id => administration_members.id) # fk_rails_... (university_id => universities.id) # fk_rails_... (website_id => communication_website_imported_websites.id) # @@ -32,7 +32,7 @@ class Communication::Website::Imported::Author < ApplicationRecord belongs_to :website, class_name: 'Communication::Website::Imported::Website' belongs_to :author, - class_name: 'Communication::Website::Author', + class_name: 'Administration::Member', optional: true before_validation :sync @@ -54,10 +54,10 @@ class Communication::Website::Imported::Author < ApplicationRecord def sync if author.nil? - self.author = Communication::Website::Author.new university: university, - website: website.website # Real website, not imported website + self.author = Administration::Member.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/imported/website.rb b/app/models/communication/website/imported/website.rb index 8965a6d01531f44e007c7380265b7c160ebd1be2..b5c6f3a19121529db50e9fd3e4430071e84beb69 100644 --- a/app/models/communication/website/imported/website.rb +++ b/app/models/communication/website/imported/website.rb @@ -60,16 +60,16 @@ class Communication::Website::Imported::Website < ApplicationRecord def sync_authors begin - skip_publish_callback(Communication::Website::Author) + skip_publish_callback(Administration::Member) wordpress.authors.each do |data| author = authors.where(university: university, identifier: data['id']).first_or_initialize author.data = data author.save end # Batch update all changes (1 query only, good for github API limits) - website.publish_authors! + website.publish_members! ensure - set_publish_callback(Communication::Website::Author) + set_publish_callback(Administration::Member) end end diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 791b8b15a8e758a8b71f4e98536b11515edd3803..e5e54b9a8d2372f1ad7b33b901ecf8b31757c035 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -24,7 +24,7 @@ # # Foreign Keys # -# fk_rails_... (author_id => communication_website_authors.id) +# fk_rails_... (author_id => administration_members.id) # fk_rails_... (communication_website_id => communication_websites.id) # fk_rails_... (university_id => universities.id) # @@ -41,9 +41,10 @@ class Communication::Website::Post < ApplicationRecord dependent: :destroy belongs_to :university belongs_to :website, + class_name: 'Communication::Website', foreign_key: :communication_website_id belongs_to :author, - class_name: 'Communication::Website::Author', + class_name: 'Administration::Member', optional: true has_and_belongs_to_many :categories, class_name: 'Communication::Website::Category', diff --git a/app/models/communication/website/with_batch_publication.rb b/app/models/communication/website/with_batch_publication.rb index 0692613531fa46127f9f0dc07ceaba68ad26326c..6f815fe2b9836cc443baafeba3791f82dc1310a3 100644 --- a/app/models/communication/website/with_batch_publication.rb +++ b/app/models/communication/website/with_batch_publication.rb @@ -8,9 +8,9 @@ module Communication::Website::WithBatchPublication end handle_asynchronously :force_publish!, queue: 'default' - def publish_authors! - commit_files_in_batch github_files.where(about_type: "Communication::Website::Author"), - "[Author] Batch update from import" + def publish_members! + commit_files_in_batch github_files.where(about_type: "Administration::Member"), + "[Member] Batch update from import" end def publish_categories! @@ -37,7 +37,7 @@ module Communication::Website::WithBatchPublication commit_files_in_batch github_files.where(about_type: [ "Education::School", "Education::Program", - "Education::Teacher" + "Administration::Member" ]), "[Education School/Program/Teacher] Batch update from import" end @@ -46,9 +46,10 @@ module Communication::Website::WithBatchPublication commit_files_in_batch github_files.where(about_type: [ "Research::Journal", "Research::Journal::Article", - "Research::Journal::Volume" + "Research::Journal::Volume", + "Administration::Member" ]), - "[Research Journal/Article/Volume] Batch update from import" + "[Research Journal/Article/Volume/Researcher] Batch update from import" end protected diff --git a/app/models/concerns/with_github_files.rb b/app/models/concerns/with_github_files.rb index e42292cca5052348c7247501af8a4f76e4ad2c4e..750f34cddd40750cfba405c8217af21ccabea1ba 100644 --- a/app/models/concerns/with_github_files.rb +++ b/app/models/concerns/with_github_files.rb @@ -28,7 +28,7 @@ module WithGithubFiles [ { identifier: "primary", - generated_path: -> { github_path_generated }, + generated_path: -> (github_file) { github_path_generated }, data: -> (github_file) { to_jekyll(github_file) }, has_media: true } diff --git a/app/models/education/program.rb b/app/models/education/program.rb index f0ae123ab941a38f0e054e06dbe9043b6763dc19..a743276345c0f1e7306e7e2af80fbe21fde84f0e 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -58,7 +58,7 @@ class Education::Program < ApplicationRecord foreign_key: 'education_program_id', association_foreign_key: 'education_school_id' has_and_belongs_to_many :teachers, - class_name: 'Education::Teacher', + class_name: 'Administration::Member', join_table: 'education_programs_teachers', foreign_key: 'education_program_id', association_foreign_key: 'education_teacher_id' diff --git a/app/models/education/teacher.rb b/app/models/education/teacher.rb deleted file mode 100644 index 90519d164795a786188aee24aa3a296890939719..0000000000000000000000000000000000000000 --- a/app/models/education/teacher.rb +++ /dev/null @@ -1,45 +0,0 @@ -# == Schema Information -# -# Table name: education_teachers -# -# id :uuid not null, primary key -# first_name :string -# last_name :string -# slug :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null -# user_id :uuid -# -# Indexes -# -# index_education_teachers_on_university_id (university_id) -# index_education_teachers_on_user_id (user_id) -# -# Foreign Keys -# -# fk_rails_... (university_id => universities.id) -# fk_rails_... (user_id => users.id) -# -class Education::Teacher < ApplicationRecord - include WithGithubFiles - include WithSlug - - has_rich_text :biography - - belongs_to :university - belongs_to :user, optional: true - has_and_belongs_to_many :programs, - class_name: 'Education::Program', - join_table: 'education_programs_teachers', - foreign_key: 'education_teacher_id', - association_foreign_key: 'education_program_id' - has_many :websites, -> { distinct }, through: :programs - - scope :ordered, -> { order(:last_name, :first_name) } - - def to_s - "#{last_name} #{first_name}" - end - -end diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index 5d28a34f01fed642f9a5c048c477a48dc7566270..981887685d0268c34db8897284bc0413deff6795 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -41,7 +41,10 @@ class Research::Journal::Article < ApplicationRecord belongs_to :journal, foreign_key: :research_journal_id belongs_to :volume, foreign_key: :research_journal_volume_id, optional: true belongs_to :updated_by, class_name: 'User' - has_and_belongs_to_many :researchers, class_name: 'Research::Researcher' + has_and_belongs_to_many :researchers, + class_name: 'Administration::Member', + join_table: :research_journal_articles_researchers, + association_foreign_key: :researcher_id has_many :websites, -> { distinct }, through: :journal validates :title, :published_at, presence: true diff --git a/app/models/research/researcher.rb b/app/models/research/researcher.rb deleted file mode 100644 index 582522b866e8ddfcc24e0a3a3e88253c12bd85e2..0000000000000000000000000000000000000000 --- a/app/models/research/researcher.rb +++ /dev/null @@ -1,40 +0,0 @@ -# == Schema Information -# -# Table name: research_researchers -# -# id :uuid not null, primary key -# first_name :string -# last_name :string -# slug :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid -# user_id :uuid -# -# Indexes -# -# idx_researcher_university (university_id) -# index_research_researchers_on_user_id (user_id) -# -# Foreign Keys -# -# fk_rails_... (university_id => universities.id) -# fk_rails_... (user_id => users.id) -# -class Research::Researcher < ApplicationRecord - include WithGithubFiles - - has_rich_text :biography - - belongs_to :university - belongs_to :user, optional: true - has_and_belongs_to_many :articles, class_name: 'Research::Journal::Article' - has_many :journals, through: :articles - has_many :websites, -> { distinct }, through: :journals - - scope :ordered, -> { order(:last_name, :first_name) } - - def to_s - "#{ first_name } #{ last_name }" - end -end diff --git a/app/models/university/with_education.rb b/app/models/university/with_education.rb index 897398899463c788cd8824f302070fa243d977d0..16be46c1b99ef01265cc1b5d8b7153a298bf5340 100644 --- a/app/models/university/with_education.rb +++ b/app/models/university/with_education.rb @@ -2,7 +2,6 @@ module University::WithEducation extend ActiveSupport::Concern included do - has_many :education_teachers, class_name: 'Education::Teacher', dependent: :destroy has_many :education_programs, class_name: 'Education::Program', dependent: :destroy has_many :education_schools, class_name: 'Education::School', dependent: :destroy diff --git a/app/models/university/with_research.rb b/app/models/university/with_research.rb index 9f624e185a3e0743bd88017ad8249c5b65735d91..67cef2638cba7d3f4f6efc4cc09e1b27040faeef 100644 --- a/app/models/university/with_research.rb +++ b/app/models/university/with_research.rb @@ -2,7 +2,6 @@ module University::WithResearch extend ActiveSupport::Concern included do - has_many :research_researchers, class_name: 'Research::Researcher', dependent: :destroy has_many :research_journals, class_name: 'Research::Journal', dependent: :destroy end end diff --git a/app/models/user.rb b/app/models/user.rb index 5257ded154caa3dda4a560d12622cd8ccc292b05..43d21694c80e7739cb6672216898b9bee50dffd6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -60,8 +60,7 @@ class User < ApplicationRecord belongs_to :university belongs_to :language - has_one :researcher, class_name: 'Research::Researcher', dependent: :nullify - has_one :author, class_name: 'Communication::Website::Author', dependent: :nullify + has_one :member, class_name: 'Administration::Member', dependent: :nullify scope :ordered, -> { order(:last_name, :first_name) } diff --git a/app/views/admin/administration/members/_form.html.erb b/app/views/admin/administration/members/_form.html.erb index 39f5ea34fc786a91b8aa29ec5c5761e3630c1542..16d8ff2e4ea5cac1599601a02d35d773e6c60e29 100644 --- a/app/views/admin/administration/members/_form.html.erb +++ b/app/views/admin/administration/members/_form.html.erb @@ -1,6 +1,6 @@ <%= simple_form_for [:admin, member] do |f| %> <div class="row"> - <div class="col-md-4"> + <div class="col-md-8"> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('content') %></h5> @@ -14,23 +14,18 @@ <%= f.input :last_name %> </div> </div> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email %> + </div> + <div class="col-md-6"> + <%= f.input :phone %> + </div> + </div> <%= f.input :biography, as: :rich_text_area %> </div> </div> </div> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= Administration::Member.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_administrative %> - </div> - </div> - </div> <div class="col-md-4"> <div class="card flex-fill w-100"> <div class="card-header"> @@ -46,6 +41,17 @@ <%= f.association :user, collection: current_university.users.ordered %> </div> </div> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= Administration::Member.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_administrative %> + </div> + </div> </div> </div> <% content_for :action_bar_right do %> diff --git a/app/views/admin/administration/members/_main_infos.html.erb b/app/views/admin/administration/members/_main_infos.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..67dfa39344c06ac59f78d932375262efcdc22dc0 --- /dev/null +++ b/app/views/admin/administration/members/_main_infos.html.erb @@ -0,0 +1,36 @@ +<div class="row"> + <div class="col-md-8"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h2 class="card-title mb-0 h5"><%= t('content') %></h2> + </div> + <div class="card-body"> + <% unless member.email.blank? %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('email') %></h3> + <p><%= link_to member.email, "mailto:#{member.email}", target: '_blank' %></p> + <% end %> + <% unless member.phone.blank? %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('phone') %></h3> + <p><%= link_to member.phone, "tel:#{member.phone}", target: '_blank' %></p> + <% end %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('biography') %></h3> + <%= member.biography %> + </div> + </div> + </div> + <div class="col-md-4"> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> + </div> + <div class="card-body"> + <h3 class="h5"><%= Administration::Member.human_attribute_name('slug') %></h3> + <p><%= member.slug %></p> + <% if member.user.present? %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('user') %></h3> + <p><%= link_to_if can?(:read, member.user), member.user, admin_user_path(member.user) %></p> + <% end %> + </div> + </div> + </div> +</div> diff --git a/app/views/admin/administration/members/index.html.erb b/app/views/admin/administration/members/index.html.erb index 0392345040995193022de9b89a9d9acbd2699da8..53ceb5e8e894e8a0a02dd2170f409a79d4fa13e0 100644 --- a/app/views/admin/administration/members/index.html.erb +++ b/app/views/admin/administration/members/index.html.erb @@ -3,7 +3,6 @@ <%= render 'admin/administration/members/list', members: @members %> <%= paginate @members, theme: 'bootstrap-5' %> - <% content_for :action_bar_right do %> <%= create_link Administration::Member %> <% end %> diff --git a/app/views/admin/administration/members/jekyll.html.erb b/app/views/admin/administration/members/jekyll.html.erb deleted file mode 100644 index 2f03cecedaa4aa58b5c13a7e3775587905b87180..0000000000000000000000000000000000000000 --- a/app/views/admin/administration/members/jekyll.html.erb +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: "<%= @teacher.to_s %>" -identifier: "<%= @teacher.id %>" -first_name: "<%= @teacher.first_name %>" -last_name: "<%= @teacher.last_name %>" -slug: "<%= @teacher.slug %>" -<% if @teacher.programs.any? %> -programs: - <% @teacher.programs.each do |program| %> - - "<%= program.id %>" - <% end %> -<% end %> -biography: > - <%= prepare_for_github @teacher.biography, @teacher.university %> ---- diff --git a/app/views/admin/administration/members/show.html.erb b/app/views/admin/administration/members/show.html.erb index 85793fc7f31395b1d53fc56a6189bdcf725999f0..5e204e537643fa2e955ac03c3b3391381d413c15 100644 --- a/app/views/admin/administration/members/show.html.erb +++ b/app/views/admin/administration/members/show.html.erb @@ -1,27 +1,6 @@ <% content_for :title, @member %> -<div class="row"> - - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> - </div> - <div class="card-body"> - <h3 class="h5"><%= Administration::Member.human_attribute_name('biography') %></h3> - <p><%= @member.biography %></p> - <h3 class="h5"><%= Administration::Member.human_attribute_name('slug') %></h3> - <p><%= @member.slug %></p> - <% if @member.user %> - <h3 class="h5"><%= Administration::Member.human_attribute_name('user') %></h3> - <p><%= link_to_if can?(:read, @member.user), @member.user, admin_user_path(@member.user) %></p> - <% end %> - </div> - </div> - </div> - -</div> - +<%= render 'main_infos', member: @member %> <% content_for :action_bar_right do %> <%= edit_link @member %> diff --git a/app/views/admin/communication/website/authors/_form.html.erb b/app/views/admin/communication/website/authors/_form.html.erb deleted file mode 100644 index 0058427acf8a742ebdc8b3757b3c1edb6cc11a0f..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/authors/_form.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<%= simple_form_for [:admin, author] do |f| %> - <div class="row"> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('content') %></h5> - </div> - <div class="card-body"> - <%= f.input :first_name %> - <%= f.input :last_name %> - <%= f.input :biography, as: :rich_text_area %> - </div> - </div> - </div> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('metadata') %></h5> - </div> - <div class="card-body"> - <%= f.input :slug, - as: :string, - input_html: author.persisted? ? {} : { - class: 'js-slug-input', - data: { source: '#communication_website_author_first_name, #communication_website_author_last_name' } - } %> - <%= f.association :user, collection: current_university.users.ordered %> - <ul> - </ul> - </div> - </div> - </div> - </div> - <% content_for :action_bar_right do %> - <%= submit f %> - <% end %> -<% end %> diff --git a/app/views/admin/communication/website/authors/_list.html.erb b/app/views/admin/communication/website/authors/_list.html.erb index 96380bb00fdd2becea41a80873084dc59d957a22..fede64fd38960172f9edc9d16ee31650c398136e 100644 --- a/app/views/admin/communication/website/authors/_list.html.erb +++ b/app/views/admin/communication/website/authors/_list.html.erb @@ -1,26 +1,15 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Communication::Website::Author.human_attribute_name('name') %></th> - <th></th> + <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= t('communication.number_of_posts') %></th> </tr> </thead> <tbody> <% authors.each do |author| %> <tr> - <td><%= link_to author, admin_communication_website_author_path(website_id: author.website.id, id: author.id) %></td> - <td class="text-end"> - <div class="btn-group" role="group"> - <%= link_to t('edit'), - edit_admin_communication_website_author_path(website_id: author.website.id, id: author.id), - class: button_classes %> - <%= link_to t('delete'), - admin_communication_website_author_path(website_id: author.website.id, id: author.id), - method: :delete, - data: { confirm: t('please-confirm') }, - class: button_classes_danger %> - </div> - </td> + <td><%= link_to author, admin_communication_website_author_path(website_id: @website.id, id: author.id) %></td> + <td><%= author.communication_website_posts.count %></td> </tr> <% end %> </tbody> diff --git a/app/views/admin/communication/website/authors/edit.html.erb b/app/views/admin/communication/website/authors/edit.html.erb deleted file mode 100644 index c5bbc5356138d7562e2cb1bf84eb422682388cbb..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/authors/edit.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% content_for :title, @author %> - -<%= render 'admin/communication/websites/sidebar' do %> - <%= render 'form', author: @author %> -<% end %> diff --git a/app/views/admin/communication/website/authors/index.html.erb b/app/views/admin/communication/website/authors/index.html.erb index e5d344d3dbb3cd8c81de2fd534fe28b8f294272a..47e934231aac9da06e6d919c3acbe633006849d8 100644 --- a/app/views/admin/communication/website/authors/index.html.erb +++ b/app/views/admin/communication/website/authors/index.html.erb @@ -1,14 +1,16 @@ -<% content_for :title, "#{Communication::Website::Author.model_name.human(count: 2)} (#{@authors.total_count})" %> +<% content_for :title, "#{t('communication.authors', count: 2)} (#{@authors.total_count})" %> <%= render 'admin/communication/websites/sidebar' do %> <div class="card"> <%= render 'admin/communication/website/authors/list', authors: @authors %> - <div class="card-body"> - <%= paginate @authors, theme: 'bootstrap-5' %> - </div> + <% if @authors.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @authors, theme: 'bootstrap-5' %> + </div> + <% end %> </div> <% end %> <% content_for :action_bar_right do %> - <%= create_link Communication::Website::Author %> + <%= link_to t('communication.manage_authors'), admin_administration_members_path, class: button_classes if can?(:read, Administration::Member) %> <% end %> diff --git a/app/views/admin/communication/website/authors/jekyll.html.erb b/app/views/admin/communication/website/authors/jekyll.html.erb index c0f06a33a4db3c6419776e19eb56559635832d02..e563627b9364e1b0a5bb7760e2fbf5c5d8947ae8 100644 --- a/app/views/admin/communication/website/authors/jekyll.html.erb +++ b/app/views/admin/communication/website/authors/jekyll.html.erb @@ -2,9 +2,11 @@ title: "<%= @author.to_s %>" slug: "<%= @author.slug %>" identifier: "<%= @author.id %>" -permalink: "/<%= @author.website.authors_github_directory %>/<%= @author.slug %>" +permalink: "/<%= @github_file.website.authors_github_directory %>/<%= @author.slug %>" first_name: "<%= @author.first_name %>" last_name: "<%= @author.last_name %>" +phone: "<%= @author.phone %>" +email: "<%= @author.email %>" biography: > <%= prepare_for_github @author.biography, @author.university %> pagination: diff --git a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb b/app/views/admin/communication/website/authors/jekyll_collection.yml.erb index f4582d8a12aeb7372274b17e1b11f849ab0190e2..76518b7276c8e5c016e4f442276a22b178433c10 100644 --- a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb +++ b/app/views/admin/communication/website/authors/jekyll_collection.yml.erb @@ -1,3 +1,3 @@ name: "<%= @author.to_s %>" identifier: "<%= @author.id %>" -link: "/<%= @author.website.authors_github_directory %>/<%= @author.slug %>" +link: "/<%= @github_file.website.authors_github_directory %>/<%= @author.slug %>" diff --git a/app/views/admin/communication/website/authors/new.html.erb b/app/views/admin/communication/website/authors/new.html.erb deleted file mode 100644 index 1d9894c1e9486eee19eeb7584a479b59a7614b6a..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/authors/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% content_for :title, Communication::Website::Author.model_name.human %> - -<%= render 'admin/communication/websites/sidebar' do %> - <%= render 'form', author: @author %> -<% end %> diff --git a/app/views/admin/communication/website/authors/show.html.erb b/app/views/admin/communication/website/authors/show.html.erb index 78bdd5f6a1046bca6c3ab054475feaa861ab1ecc..212a629cc8d964943748f9692fa9101ea578e7fc 100644 --- a/app/views/admin/communication/website/authors/show.html.erb +++ b/app/views/admin/communication/website/authors/show.html.erb @@ -1,56 +1,24 @@ <% content_for :title, @author %> <%= render 'admin/communication/websites/sidebar' do %> - <div class="row"> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('content') %></h2> - </div> - <div class="card-body"> - <h3 class="h5"><%= Communication::Website::Author.human_attribute_name('biography') %></h3> - <%= @author.biography %> - </div> - </div> - </div> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> - </div> - <div class="card-body"> - <h3 class="h5"><%= Communication::Website::Author.human_attribute_name('slug') %></h3> - <p><%= @author.slug %></p> - <% if @author.user.present? %> - <h3 class="h5"><%= Communication::Website::Author.human_attribute_name('user') %></h3> - <p><%= link_to_if can?(:read, @author.user), @author.user, admin_user_path(@author.user) %></p> - <% end %> - </div> - </div> - </div> - </div> + <%= render 'admin/administration/members/main_infos', member: @author %> + <% if @posts.total_count > 0 %> <div class="card"> <div class="card-header"> <h5><%= "#{Communication::Website::Post.model_name.human(count: 2)} (#{@posts.total_count})" %></h5> </div> <%= render 'admin/communication/website/posts/list', posts: @posts, hide_author: true %> - <div class="card-footer"> - <%= paginate @posts, theme: 'bootstrap-5' %> - </div> + <% if @posts.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @posts, theme: 'bootstrap-5' %> + </div> + <% end %> </div> <% end %> <% end %> - -<% content_for :action_bar_left do %> - <%= link_to t('communication.website.force_publication'), - publish_admin_communication_website_author_path(@author), - method: :post, - class: button_classes %> -<% end %> - <% content_for :action_bar_right do %> <%= edit_link @author %> <% end %> diff --git a/app/views/admin/communication/website/menus/index.html.erb b/app/views/admin/communication/website/menus/index.html.erb index 03a573ee74a12188af759608e0a1c46422526f36..188904d98ba4573252f927550b04d0a9921acdb0 100644 --- a/app/views/admin/communication/website/menus/index.html.erb +++ b/app/views/admin/communication/website/menus/index.html.erb @@ -3,9 +3,11 @@ <%= render 'admin/communication/websites/sidebar' do %> <div class="card"> <%= render 'admin/communication/website/menus/list', menus: @menus %> - <div class="card-footer"> - <%= paginate @menus, theme: 'bootstrap-5' %> - </div> + <% if @menus.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @menus, theme: 'bootstrap-5' %> + </div> + <% end %> </div> <% end %> diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index fb2f47dfe99a1ce57d8c6041585e462a7040be5f..7e9244dcf4f4391ab2fba84872aacb699181a809 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -26,7 +26,7 @@ } %> <%= f.input :published %> <%= f.input :published_at, html5: true %> - <%= f.association :author, collection: @website.authors.ordered if @website.authors.any? %> + <%= f.association :author, collection: current_university.members.authors.ordered %> <%= f.association :categories, as: :check_boxes, collection: @website.list_of_categories.map { |category| [ diff --git a/app/views/admin/communication/website/posts/index.html.erb b/app/views/admin/communication/website/posts/index.html.erb index ed951db104024f1f1d70b4d3cb86d1b9c429e3de..5cf39eb6317119e61e66242fbcb096d69909d0e0 100644 --- a/app/views/admin/communication/website/posts/index.html.erb +++ b/app/views/admin/communication/website/posts/index.html.erb @@ -3,9 +3,11 @@ <%= render 'admin/communication/websites/sidebar' do %> <div class="card"> <%= render 'admin/communication/website/posts/list', posts: @posts, hide_author: true, hide_category: true %> - <div class="card-footer"> - <%= paginate @posts, theme: 'bootstrap-5' %> - </div> + <% if @posts.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @posts, theme: 'bootstrap-5' %> + </div> + <% end %> </div> <% end %> diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb index eafb88153774ba0448299ca6443edbb161c70c14..a3884070e2aaa6cf1f6ee8e9f877ebad5aeb8ec0 100644 --- a/app/views/admin/communication/websites/_sidebar.html.erb +++ b/app/views/admin/communication/websites/_sidebar.html.erb @@ -25,7 +25,7 @@ path: admin_communication_website_categories_path(website_id: @website) }, { - title: Communication::Website::Author.model_name.human(count: 2), + title: t('communication.authors', count: 2), path: admin_communication_website_authors_path(website_id: @website) }, { diff --git a/app/views/admin/communication/websites/import.html.erb b/app/views/admin/communication/websites/import.html.erb index d32cdcfd0c715a2f1fe84b3d31ba7209f1228117..98e815301ce221486657d54626efe940d6d0614a 100644 --- a/app/views/admin/communication/websites/import.html.erb +++ b/app/views/admin/communication/websites/import.html.erb @@ -111,7 +111,7 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Communication::Website::Author.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('name') %></th> <th class="text-end" width="150"> </th> </tr> </thead> diff --git a/app/views/admin/communication/websites/show/_authors.html.erb b/app/views/admin/communication/websites/show/_authors.html.erb index ff6bf3f1e64c8238454cd823fc9a2ccca2e5cff0..0953a1a4149fcb6a19a65326e92c6f6668d405cc 100644 --- a/app/views/admin/communication/websites/show/_authors.html.erb +++ b/app/views/admin/communication/websites/show/_authors.html.erb @@ -7,7 +7,7 @@ </div> <h2 class="card-title"> <%= link_to admin_communication_website_authors_path(website_id: @website) do %> - <%= Communication::Website::Author.model_name.human(count: 2) %> + <%= t('communication.authors', count: 2) %> <small> - <%= t('communication.website.see_all', number: @website.authors.count) %> diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index 595a8b4ab2017c0480bda988f85c0b7401b9de83..d52e8ae27b73d47a30a58c482cfb9b8e106f62fd 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -56,7 +56,7 @@ <%= f.input :evaluation, as: :rich_text_area %> <%= f.association :teachers, as: :check_boxes, - collection: current_university.education_teachers.ordered %> + collection: current_university.members.teachers.ordered %> </div> </div> </div> diff --git a/app/views/admin/education/programs/_list.html.erb b/app/views/admin/education/programs/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9dc1c1600f1060c7512bca4ddf07b5d415e1415e --- /dev/null +++ b/app/views/admin/education/programs/_list.html.erb @@ -0,0 +1,27 @@ +<table class="table"> + <thead> + <tr> + <th><%= Education::Program.model_name.human %></th> + <th></th> + </tr> + </thead> + <tbody> + <% programs.each do |program| %> + <tr> + <td><%= link_to_if can?(:read, program), program, [:admin, program] %></td> + <td class="text-end"> + <div class="btn-group" role="group"> + <%= link_to t('edit'), + edit_admin_education_program_path(program), + class: button_classes %> + <%= link_to t('delete'), + admin_research_journal_article_path(program), + method: :delete, + data: { confirm: t('please-confirm') }, + class: button_classes_danger %> + </div> + </td> + </tr> + <% end %> + </tbody> +</table> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 2a0a8f4cbe05fc027a8531ab5b53769953d44c71..8c1d71ce979e651548c80ec910bfdea9a160f017 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -74,7 +74,7 @@ <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name('teachers') %></h3> <ul class="list-unstyled"> <% @program.teachers.ordered.each do |teacher| %> - <li><%= link_to_if can?(:read, teacher), teacher, [:admin, teacher] %></li> + <li><%= link_to_if can?(:read, teacher), teacher, admin_education_teacher_path(teacher) %></li> <% end %> </ul> <% end %> @@ -83,10 +83,6 @@ </div> </div> - - - - <% content_for :action_bar_right do %> <%= edit_link @program %> <% end %> diff --git a/app/views/admin/education/teachers/_form.html.erb b/app/views/admin/education/teachers/_form.html.erb index 36c664ab15fa822a78f3f96d4af1933cf57484e0..dd685aeacbfc35c698b164bcb65b84a1c814a1a9 100644 --- a/app/views/admin/education/teachers/_form.html.erb +++ b/app/views/admin/education/teachers/_form.html.erb @@ -1,54 +1,18 @@ -<%= simple_form_for [:admin, teacher] do |f| %> - <div class="row"> - <div class="col-md-6"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('metadata') %></h5> - </div> - <div class="card-body"> - <div class="row"> - <div class="col-md-6"> - <%= f.input :first_name %> - </div> - <div class="col-md-6"> - <%= f.input :last_name %> - </div> - </div> - <div class="row"> - <div class="col-md-6"> - <%= f.input :slug, - as: :string, - input_html: teacher.persisted? ? {} : { - class: 'js-slug-input', - data: { source: '#education_teacher_first_name, #education_teacher_last_name' } - } %> - </div> - <div class="col-md-6"> - <%= f.association :user, collection: current_university.users.ordered %> - </div> - </div> - <%= f.input :biography, as: :rich_text_area %> - </div> - </div> +<%= simple_form_for teacher, url: admin_education_teacher_path(teacher) do |f| %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= Education::Program.model_name.human(count: 2) %></h5> </div> - <div class="col-md-6"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= Education::Program.model_name.human(count: 2) %></h5> - </div> - <div class="card-body"> - <%= f.association :programs, - as: :check_boxes, - collection: current_university.list_of_programs, - label_method: ->(p) { sanitize p[:label] }, - value_method: ->(p) { p[:id] } %> - - <ul> - </ul> - </div> - </div> + <div class="card-body"> + <%= f.association :education_programs, + as: :check_boxes, + legend_tag: false, + collection: current_university.list_of_programs, + label_method: ->(p) { sanitize p[:label] }, + value_method: ->(p) { p[:id] } %> </div> </div> + <% content_for :action_bar_right do %> <%= submit f %> <% end %> diff --git a/app/views/admin/education/teachers/_list.html.erb b/app/views/admin/education/teachers/_list.html.erb index 87e1befee2026a66c4609d9467f08538e50b6c33..ec41239ac10899b7f6e144c42ee2e38f62448cd7 100644 --- a/app/views/admin/education/teachers/_list.html.erb +++ b/app/views/admin/education/teachers/_list.html.erb @@ -1,7 +1,7 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Education::Teacher.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('name') %></th> <th></th> </tr> </thead> @@ -14,11 +14,6 @@ <%= link_to t('edit'), edit_admin_education_teacher_path(teacher), class: button_classes %> - <%= link_to t('delete'), - admin_education_teacher_path(teacher), - method: :delete, - data: { confirm: t('please-confirm') }, - class: button_classes_danger %> </div> </td> </tr> diff --git a/app/views/admin/education/teachers/index.html.erb b/app/views/admin/education/teachers/index.html.erb index 44ce68d4d10ef722296bdb5430f0cf8bae26f57c..70d6d6ebc2fa0e5c81e234e542a61bd4046c9514 100644 --- a/app/views/admin/education/teachers/index.html.erb +++ b/app/views/admin/education/teachers/index.html.erb @@ -1,9 +1,11 @@ -<% content_for :title, "#{Education::Teacher.model_name.human(count: 2)} (#{@teachers.total_count})" %> +<% content_for :title, "#{t('education.teachers', count: 2)} (#{@teachers.total_count})" %> <%= render 'admin/education/teachers/list', teachers: @teachers %> -<%= paginate @teachers, theme: 'bootstrap-5' %> +<% if @teachers.total_pages > 1 %> + <%= paginate @teachers, theme: 'bootstrap-5' %> +<% end %> <% content_for :action_bar_right do %> - <%= create_link Education::Teacher %> + <%= link_to t('education.manage_teachers'), admin_administration_members_path, class: button_classes if can?(:read, Administration::Member) %> <% end %> diff --git a/app/views/admin/education/teachers/jekyll.html.erb b/app/views/admin/education/teachers/jekyll_collection.yml.erb similarity index 66% rename from app/views/admin/education/teachers/jekyll.html.erb rename to app/views/admin/education/teachers/jekyll_collection.yml.erb index 2f03cecedaa4aa58b5c13a7e3775587905b87180..954df1c552e2466c7d5985e89a5a9116c20e3f39 100644 --- a/app/views/admin/education/teachers/jekyll.html.erb +++ b/app/views/admin/education/teachers/jekyll_collection.yml.erb @@ -1,15 +1,15 @@ ---- title: "<%= @teacher.to_s %>" identifier: "<%= @teacher.id %>" first_name: "<%= @teacher.first_name %>" last_name: "<%= @teacher.last_name %>" +phone: "<%= @teacher.phone %>" +email: "<%= @teacher.email %>" slug: "<%= @teacher.slug %>" -<% if @teacher.programs.any? %> +<% if @teacher.education_programs.any? %> programs: - <% @teacher.programs.each do |program| %> + <% @teacher.education_programs.each do |program| %> - "<%= program.id %>" <% end %> <% end %> biography: > <%= prepare_for_github @teacher.biography, @teacher.university %> ---- diff --git a/app/views/admin/education/teachers/new.html.erb b/app/views/admin/education/teachers/new.html.erb deleted file mode 100644 index 9d2a7e6cf6e8da788d90d7014ed2af0fca92cd6d..0000000000000000000000000000000000000000 --- a/app/views/admin/education/teachers/new.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, Education::Teacher.model_name.human %> - -<%= render 'form', teacher: @teacher %> diff --git a/app/views/admin/education/teachers/show.html.erb b/app/views/admin/education/teachers/show.html.erb index 5cd610004735ada2715fe0ae583b9067a57f3f31..c5fd6e562429b33750401e8c8df7f5c3b1ba1de9 100644 --- a/app/views/admin/education/teachers/show.html.erb +++ b/app/views/admin/education/teachers/show.html.erb @@ -1,45 +1,22 @@ <% content_for :title, @teacher %> -<div class="row"> +<%= render 'admin/administration/members/main_infos', member: @teacher %> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> - </div> - <div class="card-body"> - <h3 class="h5"><%= Education::Teacher.human_attribute_name('biography') %></h3> - <p><%= @teacher.biography %></p> - <h3 class="h5"><%= Education::Teacher.human_attribute_name('slug') %></h3> - <p><%= @teacher.slug %></p> - <% if @teacher.user %> - <h3 class="h5"><%= Education::Teacher.human_attribute_name('user') %></h3> - <p><%= link_to_if can?(:read, @teacher.user), @teacher.user, admin_user_path(@teacher.user) %></p> - <% end %> - </div> - </div> - </div> - <% if @teacher.programs.any? %> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= Education::Teacher.human_attribute_name('programs') %></h2> - </div> - <div class="card-body"> - <ul class="list-unstyled"> - <% @teacher.programs.ordered.each do |program| %> - <li><%= link_to_if can?(:read, program), program, [:admin, program] %></li> - <% end %> - </ul> - </div> - </div> +<% if @programs.total_count > 0 %> + <div class="card"> + <div class="card-header"> + <h2 class="card-title mb-0 h5"><%= "#{Education::Program.model_name.human(count: 2)} (#{@programs.total_count})" %></h2> </div> - <% end %> - -</div> - + <%= render 'admin/education/programs/list', programs: @programs %> + <% if @programs.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @programs, theme: 'bootstrap-5' %> + </div> + <% end %> + </div> +<% end %> <% content_for :action_bar_right do %> - <%= edit_link @teacher %> + <%= link_to t('edit'), edit_admin_education_teacher_path(@teacher), class: button_classes if can?(:edit, Education::Program) %> <% end %> diff --git a/app/views/admin/research/journal/articles/_form.html.erb b/app/views/admin/research/journal/articles/_form.html.erb index a37138e11d88486046989f1d9ca85f82cfa622af..1ca5b93cba7b00cfb96cfab443fba83a72197696 100644 --- a/app/views/admin/research/journal/articles/_form.html.erb +++ b/app/views/admin/research/journal/articles/_form.html.erb @@ -29,7 +29,7 @@ <%= f.association :volume, collection: @journal.volumes, label: Research::Journal::Volume.model_name.human %> <%= f.input :published_at, html5: true %> <%= f.input :keywords, as: :text, input_html: { rows: 2 } %> - <%= f.association :researchers, collection: current_university.research_researchers.ordered, as: :check_boxes %> + <%= f.association :researchers, collection: current_university.members.researchers.ordered, as: :check_boxes %> </div> </div> </div> diff --git a/app/views/admin/research/journal/articles/_list.html.erb b/app/views/admin/research/journal/articles/_list.html.erb index 3d8425c402f71789117f21e81b67e27bda38eb99..d5e338ea9354588dc8c48003fc30b49f1547a70d 100644 --- a/app/views/admin/research/journal/articles/_list.html.erb +++ b/app/views/admin/research/journal/articles/_list.html.erb @@ -9,15 +9,15 @@ <tbody> <% articles.each do |article| %> <tr> - <td><%= link_to article, admin_research_journal_article_path(journal_id: @journal, id: article) %></td> + <td><%= link_to article, admin_research_journal_article_path(journal_id: article.journal, id: article) %></td> <td><%= article.published_at %></td> <td class="text-end"> <div class="btn-group" role="group"> <%= link_to t('edit'), - edit_admin_research_journal_article_path(journal_id: @journal, id: article), + edit_admin_research_journal_article_path(journal_id: article.journal, id: article), class: button_classes %> <%= link_to t('delete'), - admin_research_journal_article_path(journal_id: @journal, id: article), + admin_research_journal_article_path(journal_id: article.journal, id: article), method: :delete, data: { confirm: t('please-confirm') }, class: button_classes_danger %> diff --git a/app/views/admin/research/journal/articles/show.html.erb b/app/views/admin/research/journal/articles/show.html.erb index 948d91e065718bb69a2423f4188ec5a6aea0b9ff..3d1b9e68b4d0ad31a4aea4fa627382e1f2096d3f 100644 --- a/app/views/admin/research/journal/articles/show.html.erb +++ b/app/views/admin/research/journal/articles/show.html.erb @@ -40,7 +40,7 @@ <h3 class="h5"><%= Research::Journal::Article.human_attribute_name('researchers') %></h3> <ul class="list-unstyled mb-0"> <% @article.researchers.each do |researcher| %> - <li><%= link_to researcher, [:admin, researcher] %></li> + <li><%= link_to researcher, admin_research_researcher_path(researcher) %></li> <% end %> </ul> <% end %> diff --git a/app/views/admin/research/researchers/_form.html.erb b/app/views/admin/research/researchers/_form.html.erb deleted file mode 100644 index aecb1a41694cc74c808767e5d38b0e293f35983f..0000000000000000000000000000000000000000 --- a/app/views/admin/research/researchers/_form.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -<%= simple_form_for [:admin, researcher] do |f| %> -<div class="row"> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-body"> - <%= f.input :first_name %> - <%= f.input :last_name %> - <%= f.input :slug, - as: :string, - input_html: researcher.persisted? ? {} : { - class: 'js-slug-input', - data: { source: '#research_researcher_first_name, #research_researcher_last_name' } - } %> - <%= f.association :user, collection: current_university.users.ordered %> - </div> - </div> - </div> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-body"> - <%= f.input :biography, as: :rich_text_area %> - </div> - </div> - </div> -</div> - <% content_for :action_bar_right do %> - <%= submit f %> - <% end %> -<% end %> diff --git a/app/views/admin/research/researchers/edit.html.erb b/app/views/admin/research/researchers/edit.html.erb deleted file mode 100644 index fbfc680d709b3d64b2f126009632555575c82fed..0000000000000000000000000000000000000000 --- a/app/views/admin/research/researchers/edit.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, @researcher%> - -<%= render 'form', researcher: @researcher %> diff --git a/app/views/admin/research/researchers/index.html.erb b/app/views/admin/research/researchers/index.html.erb index 3f4104f02185366ce01c22da9ff542901d99b5fb..eb0e7bb1d8298cb326262210814682bd7241c04e 100644 --- a/app/views/admin/research/researchers/index.html.erb +++ b/app/views/admin/research/researchers/index.html.erb @@ -1,34 +1,27 @@ -<% content_for :title, Research::Researcher.model_name.human(count: 2) %> +<% content_for :title, t('researcher.researchers', count: 2) %> <table class="table"> <thead> <tr> - <th><%= Research::Researcher.human_attribute_name('last_name') %></th> - <th><%= Research::Researcher.human_attribute_name('first_name') %></th> - <th><%= Research::Researcher.human_attribute_name('user') %></th> - <th></th> + <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= t('research.number_of_articles') %></th> </tr> </thead> <tbody> <% @researchers.each do |researcher| %> <tr> - <td><%= link_to researcher.last_name, [:admin, researcher] %></td> - <td><%= link_to researcher.first_name, [:admin, researcher] %></td> - <td><%= link_to researcher.user, [:admin, researcher.user] if researcher.user %></td> - <td class="text-end"> - <div class="btn-group" role="group"> - <%= edit_link researcher %> - <%= destroy_link researcher %> - </div> - </td> + <td><%= link_to researcher, admin_research_researcher_path(researcher) %></td> + <td><%= researcher.research_journal_articles.count %></td> </tr> <% end %> </tbody> </table> -<%= paginate @researchers, theme: 'bootstrap-5' %> +<% if @researchers.total_pages > 1 %> + <%= paginate @researchers, theme: 'bootstrap-5' %> +<% end %> <% content_for :action_bar_right do %> - <%= create_link Research::Researcher %> + <%= link_to t('research.manage_researchers'), admin_administration_members_path, class: button_classes if can?(:read, Administration::Member) %> <% end %> diff --git a/app/views/admin/research/researchers/jekyll.html.erb b/app/views/admin/research/researchers/jekyll_collection.yml.erb similarity index 63% rename from app/views/admin/research/researchers/jekyll.html.erb rename to app/views/admin/research/researchers/jekyll_collection.yml.erb index 698fec862ab277f4ff2e6e69187fcbd0c7cfa7e2..3a539eebb52076a5555017fbab40bce82483dc30 100644 --- a/app/views/admin/research/researchers/jekyll.html.erb +++ b/app/views/admin/research/researchers/jekyll_collection.yml.erb @@ -1,7 +1,7 @@ ---- -title: "<%= "#{ @researcher }"%>" +title: "<%= @researcher.to_s %>" first_name: "<%= @researcher.first_name %>" last_name: "<%= @researcher.last_name %>" +phone: "<%= @researcher.phone %>" +email: "<%= @researcher.email %>" biography: > <%= prepare_for_github @researcher.biography, @researcher.university %> ---- diff --git a/app/views/admin/research/researchers/new.html.erb b/app/views/admin/research/researchers/new.html.erb deleted file mode 100644 index 862c45f3c3e9aa7602c9d0626f0e8c8633262170..0000000000000000000000000000000000000000 --- a/app/views/admin/research/researchers/new.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, Research::Researcher.model_name.human %> - -<%= render 'form', researcher: @researcher %> diff --git a/app/views/admin/research/researchers/show.html.erb b/app/views/admin/research/researchers/show.html.erb index e50282dea86fddaf6f1575823337bf35ee603f8e..7c58ad5f896132ad4ce4beff34adce8481a1fd99 100644 --- a/app/views/admin/research/researchers/show.html.erb +++ b/app/views/admin/research/researchers/show.html.erb @@ -1,40 +1,20 @@ <% content_for :title, @researcher %> -<div class="row"> - <div class="col-md-8"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('content') %></h2> - </div> - <div class="card-body"> - <h3 class="h5"><%= Research::Researcher.human_attribute_name('biography') %></h3> - <%= @researcher.biography %> - <% if @researcher.articles.any? %> - <h3 class="h5 mt-4"><%= Research::Researcher.human_attribute_name('articles') %></h3> - <ul> - <% @researcher.articles.each do |article| %> - <li><%= link_to article, admin_research_journal_article_path(journal_id: article.journal.id, id: article) %></li> - <% end %> - </ul> - <% end %> - </div> +<%= render 'admin/administration/members/main_infos', member: @researcher %> + +<% if @articles.total_count > 0 %> + <div class="card"> + <div class="card-header"> + <h2 class="card-title mb-0 h5"><%= "#{Research::Journal::Article.model_name.human(count: 2)} (#{@articles.total_count})" %></h2> </div> - </div> - <div class="col-md-4"> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> + <%= render 'admin/research/journal/articles/list', articles: @articles %> + <% if @articles.total_pages > 1 %> + <div class="card-footer"> + <%= paginate @articles, theme: 'bootstrap-5' %> </div> - <div class="card-body"> - <% if @researcher.user %> - <h3 class="h5"><%= Research::Researcher.human_attribute_name('user') %></h3> - <p><%= link_to @researcher.user, [:admin, @researcher.user] %></p> - <% end %> - </div> - </div> + <% end %> </div> -</div> - +<% end %> <% content_for :action_bar_right do %> <%= edit_link @researcher %> diff --git a/app/views/devise/two_factor_authentication/show.html.erb b/app/views/devise/two_factor_authentication/show.html.erb index 4b45dd0b001969e1bae90e59f3fb9dc176a2ed78..13940170719d2389746f1ee9cd43a693af16f91d 100644 --- a/app/views/devise/two_factor_authentication/show.html.erb +++ b/app/views/devise/two_factor_authentication/show.html.erb @@ -26,7 +26,7 @@ <%= link_to t('devise.two_factor_authentication.send_code_instead'), [:resend_code, resource_name, :two_factor_authentication] %> <% end %> <% unless resource.mobile_phone.blank? # when phone is blank default code method is already :email so we don't need another link %> - <%= link_to t('devise.two_factor_authentication.send_email_code'), [:resend_code, resource_name, :two_factor_authentication, delivery_method: :email] %> + • <%= link_to t('devise.two_factor_authentication.send_email_code'), [:resend_code, resource_name, :two_factor_authentication, delivery_method: :email] %> <% end %> </p> </div> diff --git a/config/admin_navigation.rb b/config/admin_navigation.rb index 4ff4e4eb8051d8a3c2da4d346e17c799fe1201be..39ef3a21a0a3649d3fdd43b5eeb226a68e22fd90 100644 --- a/config/admin_navigation.rb +++ b/config/admin_navigation.rb @@ -8,16 +8,16 @@ SimpleNavigation::Configuration.run do |navigation| if can?(:read, Education::Program) primary.item :education, Education.model_name.human, nil, { kind: :header } - primary.item :education, Education::Teacher.model_name.human(count: 2), admin_education_teachers_path, { icon: 'user-graduate' } + primary.item :education, t('education.teachers', count: 2), admin_education_teachers_path, { icon: 'user-graduate' } if can?(:read, Administration::Member) primary.item :education, Education::School.model_name.human(count: 2), admin_education_schools_path, { icon: 'university' } if can?(:read, Education::School) primary.item :education_programs, Education::Program.model_name.human(count: 2), admin_education_programs_path, { icon: 'graduation-cap' } if can?(:read, Education::Program) primary.item :education, 'Ressources éducatives', nil, { icon: 'laptop' } primary.item :education, 'Feedbacks', nil, { icon: 'comments' } end - if can?(:read, Research::Researcher) || can?(:read, Research::Journal) + if can?(:read, Research::Journal) primary.item :research, Research.model_name.human, nil, { kind: :header } - primary.item :research_researchers, Research::Researcher.model_name.human(count: 2), admin_research_researchers_path(journal_id: nil), { icon: 'microscope' } if can?(:read, Research::Researcher) + primary.item :research_researchers, t('research.researchers', count: 2), admin_research_researchers_path(journal_id: nil), { icon: 'microscope' } if can?(:read, Administration::Member) primary.item :research, 'Laboratoires', nil, { icon: 'flask' } primary.item :research, 'Veille', nil, { icon: 'eye' } primary.item :research_journals, Research::Journal.model_name.human(count: 2), admin_research_journals_path, { icon: 'newspaper' } if can?(:read, Research::Journal) diff --git a/config/locales/administration/en.yml b/config/locales/administration/en.yml index 05c6ad9c7cdf6ab6b30aaf16986166c8b48663ff..a5dd96be006620f568aac9e9f52ef54e1f944423 100644 --- a/config/locales/administration/en.yml +++ b/config/locales/administration/en.yml @@ -17,6 +17,9 @@ en: administration/member: abilities: Abilities biography: Biography + communication_website_posts: Posts + education_programs: Programs + email: Email first_name: First name is_administrative: Administrative staff is_author: Author @@ -24,6 +27,8 @@ en: is_teacher: Teacher last_name: Last name name: Name + phone: Phone + research_journal_articles: Articles slug: Slug user: User administration/qualiopi/criterion: @@ -40,3 +45,10 @@ en: requirement: Requirement non_conformity: Non-conformity glossary: Glossary + simple_form: + hints: + administration_member: + is_administrative: "Is part of administrative staff for a school." + is_author: "Writes posts for websites." + is_researcher: "Writes articles for journals." + is_teacher: "Teaches in Schools." diff --git a/config/locales/administration/fr.yml b/config/locales/administration/fr.yml index e02744d33529abd46506d988026551faf16bc944..5c62bd0900a84ed07e37808b1ec2358606b7d773 100644 --- a/config/locales/administration/fr.yml +++ b/config/locales/administration/fr.yml @@ -17,6 +17,9 @@ fr: administration/member: abilities: Responsabilités biography: Biographie + communication_website_posts: Actualités + education_programs: Formations + email: Email first_name: Prénom is_administrative: Personnel administratif is_author: Auteur·rice @@ -24,6 +27,8 @@ fr: is_teacher: Enseignant·e last_name: Nom de famille name: Nom + phone: Téléphone + research_journal_articles: Articles slug: Slug user: Utilisateur administration/qualiopi/criterion: @@ -40,3 +45,10 @@ fr: requirement: Obligations spécifiques non_conformity: Non-conformité glossary: Glossaire + simple_form: + hints: + administration_member: + is_administrative: "Fait partie du personnel administratif d'une école." + is_author: "Écrit des articles pour les sites." + is_researcher: "Écrit des articles dans des revues scientifiques." + is_teacher: "Enseigne dans des formations." diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 232963c1be73a04010f48f82915b543a6668fd36..c7dc5a884fb6bcceb7a249de98826ba3a3c680f8 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -1,23 +1,4 @@ en: - communication: - website: - force_publication: 'Force publication' - imported: - from: Imported from - launch: Launch import - launched: Import in progress - original_url: Original URL - media: - file_size: File size - not_imported_yet: Not imported yet - refresh: Refresh import - show: Show import - pending: Import in progress - last_pages: Last pages - last_posts: Last posts - posts: - new_curation: New curation - see_all: See the full list (%{number} elements) activemodel: models: communication: Communication @@ -119,6 +100,30 @@ en: text: Text title: Title website: Website + communication: + authors: + one: Author + other: Authors + manage_authors: Manage authors + number_of_posts: Nunber of posts + website: + force_publication: 'Force publication' + imported: + from: Imported from + launch: Launch import + launched: Import in progress + original_url: Original URL + media: + file_size: File size + not_imported_yet: Not imported yet + refresh: Refresh import + show: Show import + pending: Import in progress + last_pages: Last pages + last_posts: Last posts + posts: + new_curation: New curation + see_all: See the full list (%{number} elements) enums: communication/website/menu/item: kind: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 8c70d43619f22b5e1e4da14e11df07e0c1500c23..80b8097fbcace9f0a7606f2c9b471660af7809c5 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -1,23 +1,4 @@ fr: - communication: - website: - force_publication: 'Forcer la publication' - imported: - from: Importé depuis - launch: Importer le site - launched: Importation en cours - original_url: URL originale - media: - file_size: Taille du fichier - not_imported_yet: Non importé pour le moment - refresh: Relancer l'import - show: Voir l'import - pending: Import en cours - last_pages: Dernières pages - last_posts: Dernières actualités - posts: - new_curation: Nouvelle curation - see_all: Voir la liste complète (%{number} éléments) activemodel: models: communication: Communication @@ -26,9 +7,6 @@ fr: communication/website: one: Site Web other: Sites Web - communication/website/author: - one: Auteur·rice - other: Auteur·rice·s communication/website/category: one: Catégorie other: Catégories @@ -66,13 +44,6 @@ fr: programs_github_directory: Dossier GitHub des formations staff_github_directory: Dossier GitHub de l'équipe url: URL - communication/website/author: - biography: Biographie - first_name: Prénom - last_name: Nom de famille - name: Nom - slug: Slug - user: Utilisateur communication/website/category: children: Catégories enfants description: Description @@ -119,6 +90,30 @@ fr: text: Texte title: Titre website: Site Web + communication: + authors: + one: Auteur·rice + other: Auteur·rice·s + manage_authors: Gérer les auteur·rice·s + number_of_posts: Nombre d'actualités + website: + force_publication: 'Forcer la publication' + imported: + from: Importé depuis + launch: Importer le site + launched: Importation en cours + original_url: URL originale + media: + file_size: Taille du fichier + not_imported_yet: Non importé pour le moment + refresh: Relancer l'import + show: Voir l'import + pending: Import en cours + last_pages: Dernières pages + last_posts: Dernières actualités + posts: + new_curation: Nouvelle curation + see_all: Voir la liste complète (%{number} éléments) enums: communication/website/menu/item: kind: diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index 759a29b7db1d07b357c468271db3cbaef33d8547..375f0b15167ab86051b660f30f0291e8fdc16c69 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -10,9 +10,6 @@ en: education/school: one: School other: Schools - education/teacher: - one: Teacher - other: Teachers attributes: education/program: accessibility: Accessibilité @@ -42,19 +39,16 @@ en: programs: Programs provided websites: Associated websites zipcode: Zipcode - education/teacher: - biography: Biography - first_name: First name - last_name: Last name - name: Name - programs: Programs done - slug: Slug - user: User education: + manage_teachers: Manage teachers + number_of_programs: Number of programs program: educational_informations: Educational informations main_informations: Main informations useful_informations: Useful informations + teachers: + one: Teacher + other: Teachers enums: education/program: level: diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index 2a0d3172a01832f78dbf6909bd1a7b8066639ac6..edf5d22d099581f1792be1ba007ff54131a1ca28 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -10,9 +10,6 @@ fr: education/school: one: École other: Écoles - education/teacher: - one: Enseignant·e - other: Enseignants·es attributes: education/program: accessibility: Accessibilité @@ -42,19 +39,16 @@ fr: programs: Formations dispensées websites: Sites webs associés zipcode: Code postal - education/teacher: - biography: Biographie - first_name: Prénom - last_name: Nom de famille - name: Nom - programs: Formations assurées - slug: Slug - user: Utilisateur education: + manage_teachers: Gérer les Enseignants·es + number_of_programs: Nombre de formations program: educational_informations: Informations pédagogiques main_informations: Informations essentielles useful_informations: Informations pratiques + teachers: + one: Enseignant·e + other: Enseignants·es enums: education/program: level: diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index 0f66cd6e10ff42e230358ae16ada1a719d1cd556..43651a895ebeddb2a5a0e6c3c0bc9c4b292d4549 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -13,9 +13,6 @@ en: research/journal/volume: one: Volume other: Volumes - research/researcher: - one: Researcher - other: Researchers attributes: research/journal: issn: ISSN @@ -36,11 +33,12 @@ en: number: Number published_at: Published at title: Title - research/researcher: - biography: Biography - first_name: First name - last_name: Last name - user: User + research: + manage_researchers: Managege researchers + number_of_articles: Number of articles + researchers: + one: Researcher + other: Researchers simple_form: hints: research_journal_volume: diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index 454e569f8a7926af010a4d590c84cb48fd8cfece..345543bf2823ad464aa6b653c53ef2504db5d945 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -13,9 +13,6 @@ fr: research/journal/volume: one: Volumes other: Volumes - research/researcher: - one: Chercheu·r·se - other: Chercheu·rs·ses attributes: research/journal: issn: ISSN @@ -36,11 +33,12 @@ fr: number: Numéro published_at: Publié le title: Titre - research/researcher: - biography: Biographie - first_name: Prénom - last_name: Nom - user: Utilisateur + research: + manage_researchers: Gérer les Chercheu·rs·ses + number_of_articles: Nombre d'articles + researchers: + one: Chercheu·r·se + other: Chercheu·rs·ses simple_form: hints: research_journal_volume: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 0b94e89b9197da0d94009abb9ed40dda2e4aa77c..ec6dc3e695537e74990146796a5f2891dc0bf66e 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -25,11 +25,7 @@ namespace :communication do post :publish end end - resources :authors, controller: 'website/authors' do - member do - post :publish - end - end + resources :authors, controller: 'website/authors', only: [:index, :show] resources :posts, controller: 'website/posts' do member do post :publish diff --git a/config/routes/admin/education.rb b/config/routes/admin/education.rb index 0a11f525cbeacf0d1abf2f2ef8a767afa65d5d15..8d4ae678f2d31dc2b67190a5493aa82a677502b7 100644 --- a/config/routes/admin/education.rb +++ b/config/routes/admin/education.rb @@ -1,5 +1,6 @@ namespace :education do - resources :teachers, :schools + resources :teachers, except: [:create, :destroy] + resources :schools resources :programs do collection do post :reorder diff --git a/config/routes/admin/research.rb b/config/routes/admin/research.rb index 45d9c173d4c6521ea482b0bf63dce8fe21915e47..678f7e597e92990a02acc56ed29c64a429cd31c0 100644 --- a/config/routes/admin/research.rb +++ b/config/routes/admin/research.rb @@ -1,5 +1,5 @@ namespace :research do - resources :researchers + resources :researchers, only: [:index, :show] resources :journals do resources :volumes, controller: 'journal/volumes' resources :articles, controller: 'journal/articles' diff --git a/db/latest.dump b/db/latest.dump deleted file mode 100644 index 34b011a83ec926ea6385c1ab1cab29f573469439..0000000000000000000000000000000000000000 Binary files a/db/latest.dump and /dev/null differ diff --git a/db/migrate/20211214150454_change_index_on_communication_website_post_author.rb b/db/migrate/20211214150454_change_index_on_communication_website_post_author.rb new file mode 100644 index 0000000000000000000000000000000000000000..708b31c7c8802d399b10b7a75698ab1568cf8512 --- /dev/null +++ b/db/migrate/20211214150454_change_index_on_communication_website_post_author.rb @@ -0,0 +1,6 @@ +class ChangeIndexOnCommunicationWebsitePostAuthor < ActiveRecord::Migration[6.1] + def change + remove_foreign_key :communication_website_posts, column: :author_id + add_foreign_key :communication_website_posts, :administration_members, column: :author_id + end +end diff --git a/db/migrate/20211214163501_change_index_on_research_journal_article_researcher.rb b/db/migrate/20211214163501_change_index_on_research_journal_article_researcher.rb new file mode 100644 index 0000000000000000000000000000000000000000..a086077cf008ca94aef2bc956673f64e1d0df350 --- /dev/null +++ b/db/migrate/20211214163501_change_index_on_research_journal_article_researcher.rb @@ -0,0 +1,6 @@ +class ChangeIndexOnResearchJournalArticleResearcher < ActiveRecord::Migration[6.1] + def change + remove_foreign_key :research_journal_articles_researchers, column: :researcher_id + add_foreign_key :research_journal_articles_researchers, :administration_members, column: :researcher_id + end +end diff --git a/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb b/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb new file mode 100644 index 0000000000000000000000000000000000000000..ad067aecf865aba862a602525156ae6217865923 --- /dev/null +++ b/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb @@ -0,0 +1,6 @@ +class AddEmailAndPhoneToAdministrationMembers < ActiveRecord::Migration[6.1] + def change + add_column :administration_members, :phone, :string + add_column :administration_members, :email, :string + end +end diff --git a/db/migrate/20211215110752_change_index_on_education_program_teachers.rb b/db/migrate/20211215110752_change_index_on_education_program_teachers.rb new file mode 100644 index 0000000000000000000000000000000000000000..d3772bfbcaac7edaae6a3b206f327bff433953d5 --- /dev/null +++ b/db/migrate/20211215110752_change_index_on_education_program_teachers.rb @@ -0,0 +1,6 @@ +class ChangeIndexOnEducationProgramTeachers < ActiveRecord::Migration[6.1] + def change + add_foreign_key :education_programs_teachers, :administration_members, column: :education_teacher_id + + end +end diff --git a/db/migrate/20211215133833_remove_unused_models.rb b/db/migrate/20211215133833_remove_unused_models.rb new file mode 100644 index 0000000000000000000000000000000000000000..41ea43ca5b7b8ce4fb8c4e5243b777f1f0598578 --- /dev/null +++ b/db/migrate/20211215133833_remove_unused_models.rb @@ -0,0 +1,10 @@ +class RemoveUnusedModels < ActiveRecord::Migration[6.1] + def change + remove_foreign_key :communication_website_imported_authors, column: :author_id + add_foreign_key :communication_website_imported_authors, :administration_members, column: :author_id + + drop_table :education_teachers + drop_table :research_researchers + drop_table :communication_website_authors + end +end diff --git a/db/schema.rb b/db/schema.rb index 73cdaade806fd993625235120030d34e259d60bc..f88c9b41c37d28762bfca286dd472f0b97d747c5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_12_14_101323) do +ActiveRecord::Schema.define(version: 2021_12_15_133833) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -68,6 +68,8 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do t.boolean "is_administrative" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "phone" + t.string "email" t.index ["university_id"], name: "index_administration_members_on_university_id" t.index ["user_id"], name: "index_administration_members_on_user_id" end @@ -94,21 +96,6 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id" end - create_table "communication_website_authors", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "university_id", null: false - t.uuid "user_id" - t.uuid "communication_website_id", null: false - t.string "last_name" - t.string "first_name" - t.string "slug" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.text "github_path" - t.index ["communication_website_id"], name: "idx_comm_website_authors_on_communication_website_id" - t.index ["university_id"], name: "index_communication_website_authors_on_university_id" - t.index ["user_id"], name: "index_communication_website_authors_on_user_id" - end - create_table "communication_website_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false @@ -418,18 +405,6 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do t.index ["university_id"], name: "index_education_schools_on_university_id" end - create_table "education_teachers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "university_id", null: false - t.string "first_name" - t.string "last_name" - t.string "slug" - t.uuid "user_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["university_id"], name: "index_education_teachers_on_university_id" - t.index ["user_id"], name: "index_education_teachers_on_user_id" - end - create_table "languages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "iso_code" @@ -491,18 +466,6 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do t.index ["university_id"], name: "index_research_journals_on_university_id" end - create_table "research_researchers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "first_name" - t.string "last_name" - t.uuid "user_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.uuid "university_id" - t.string "slug" - t.index ["university_id"], name: "idx_researcher_university" - t.index ["user_id"], name: "index_research_researchers_on_user_id" - end - create_table "universities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "identifier" @@ -566,9 +529,6 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do add_foreign_key "administration_members", "universities" add_foreign_key "administration_members", "users" add_foreign_key "administration_qualiopi_indicators", "administration_qualiopi_criterions", column: "criterion_id" - add_foreign_key "communication_website_authors", "communication_websites" - add_foreign_key "communication_website_authors", "universities" - add_foreign_key "communication_website_authors", "users" add_foreign_key "communication_website_categories", "communication_website_categories", column: "parent_id" add_foreign_key "communication_website_categories", "communication_websites" add_foreign_key "communication_website_categories", "education_programs", column: "program_id" @@ -576,7 +536,7 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do add_foreign_key "communication_website_github_files", "communication_websites", column: "website_id" add_foreign_key "communication_website_homes", "communication_websites" add_foreign_key "communication_website_homes", "universities" - add_foreign_key "communication_website_imported_authors", "communication_website_authors", column: "author_id" + add_foreign_key "communication_website_imported_authors", "administration_members", column: "author_id" add_foreign_key "communication_website_imported_authors", "communication_website_imported_websites", column: "website_id" add_foreign_key "communication_website_imported_authors", "universities" add_foreign_key "communication_website_imported_categories", "communication_website_categories", column: "category_id" @@ -604,26 +564,23 @@ ActiveRecord::Schema.define(version: 2021_12_14_101323) do add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id" add_foreign_key "communication_website_pages", "communication_websites" add_foreign_key "communication_website_pages", "universities" - add_foreign_key "communication_website_posts", "communication_website_authors", column: "author_id" + add_foreign_key "communication_website_posts", "administration_members", column: "author_id" add_foreign_key "communication_website_posts", "communication_websites" add_foreign_key "communication_website_posts", "universities" add_foreign_key "communication_websites", "universities" add_foreign_key "education_programs", "education_programs", column: "parent_id" add_foreign_key "education_programs", "universities" + add_foreign_key "education_programs_teachers", "administration_members", column: "education_teacher_id" add_foreign_key "education_schools", "universities" - add_foreign_key "education_teachers", "universities" - add_foreign_key "education_teachers", "users" add_foreign_key "research_journal_articles", "research_journal_volumes" add_foreign_key "research_journal_articles", "research_journals" add_foreign_key "research_journal_articles", "universities" add_foreign_key "research_journal_articles", "users", column: "updated_by_id" + add_foreign_key "research_journal_articles_researchers", "administration_members", column: "researcher_id" add_foreign_key "research_journal_articles_researchers", "research_journal_articles", column: "article_id" - add_foreign_key "research_journal_articles_researchers", "research_researchers", column: "researcher_id" add_foreign_key "research_journal_volumes", "research_journals" add_foreign_key "research_journal_volumes", "universities" add_foreign_key "research_journals", "universities" - add_foreign_key "research_researchers", "universities" - add_foreign_key "research_researchers", "users" add_foreign_key "users", "languages" add_foreign_key "users", "universities" end