diff --git a/Gemfile.lock b/Gemfile.lock index 1299adfc7f89b54a3958383f0a07096cd4d82dac..2dc460e488dc3dc424046748a85493d57b61d6ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,11 +76,11 @@ GEM annotate (3.1.1) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 14.0) - autoprefixer-rails (10.4.0.0) + autoprefixer-rails (10.4.2.0) execjs (~> 2) aws-eventstream (1.2.0) - aws-partitions (1.543.0) - aws-sdk-core (3.125.0) + aws-partitions (1.548.0) + aws-sdk-core (3.125.3) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) @@ -88,7 +88,7 @@ GEM aws-sdk-kms (1.53.0) aws-sdk-core (~> 3, >= 3.125.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.110.0) + aws-sdk-s3 (1.111.1) aws-sdk-core (~> 3, >= 3.125.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) @@ -96,7 +96,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.9.3) + bootsnap (1.9.4) msgpack (~> 1.0) bootstrap (5.1.3) autoprefixer-rails (>= 9.1.0) @@ -123,7 +123,7 @@ GEM xpath (~> 3.2) childprocess (4.1.0) concurrent-ruby (1.1.9) - countries (4.1.3) + countries (4.2.1) i18n_data (~> 0.15.0) sixarm_ruby_unaccent (~> 1.1) country_select (6.0.0) @@ -154,22 +154,23 @@ GEM domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) encryptor (3.0.0) - enum_help (0.0.17) + enum_help (0.0.18) activesupport (>= 3.0.0) erubi (1.10.0) ethon (0.15.0) ffi (>= 1.15.0) execjs (2.8.1) - faraday (1.8.0) + faraday (1.9.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) + faraday-net_http_persistent (~> 1.0) faraday-patron (~> 1.0) faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-cookie_jar (0.0.7) faraday (>= 0.8.0) @@ -182,14 +183,17 @@ GEM faraday-http-cache (2.2.0) faraday (>= 0.8) faraday-httpclient (1.0.1) + faraday-multipart (1.0.3) + multipart-post (>= 1.2, < 3) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) + faraday-retry (1.0.3) faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - ffi (1.15.4) + ffi (1.15.5) figaro (1.2.0) thor (>= 0.14.0, < 2) front_matter_parser (1.0.1) @@ -211,7 +215,7 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jmespath (1.4.0) + jmespath (1.5.0) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -234,7 +238,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - listen (3.7.0) + listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.13.0) @@ -257,7 +261,7 @@ GEM method_source (1.0.0) mini_magick (4.11.0) mini_mime (1.1.2) - mini_portile2 (2.6.1) + mini_portile2 (2.7.1) minitest (5.15.0) msgpack (1.4.2) multipart-post (2.1.1) @@ -266,10 +270,10 @@ GEM nested_form (0.3.2) nesty (1.0.2) nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.1) + mini_portile2 (~> 2.7.0) racc (~> 1.4) - octokit (4.21.0) + octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) orm_adapter (0.5.0) @@ -348,7 +352,8 @@ GEM childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) - sib-api-v3-sdk (7.5.0) + sib-api-v3-sdk (8.0.0) + addressable (~> 2.3, >= 2.3.0) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) simple-navigation (4.3.0) @@ -379,7 +384,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - thor (1.1.0) + thor (1.2.1) tilt (2.0.10) typhoeus (1.4.0) ethon (>= 0.9.0) diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 54af5d9dfc22bdbab709616ff5c0f291e3c4f21c..99bd27a0e9cc62633547d714daa14247e092d1a8 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -73,7 +73,9 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati def website_params params.require(:communication_website).permit( :name, :url, :repository, :access_token, :about_type, :about_id, - :authors_github_directory, :posts_github_directory, :programs_github_directory, :staff_github_directory + :authors_github_directory, :posts_github_directory, :programs_github_directory, + :research_articles_github_directory, :research_volumes_github_directory, + :staff_github_directory ) end end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 75c044ef5a65375f1e6eee8db7ce6733f81877b5..0d5fa3e254bfadee90e67b4416164848961f13b2 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -2,20 +2,22 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string -# access_token :string -# authors_github_directory :string default("authors") -# name :string -# posts_github_directory :string default("posts") -# programs_github_directory :string default("programs") -# repository :string -# staff_github_directory :string default("staff") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid -# university_id :uuid not null +# id :uuid not null, primary key +# about_type :string +# access_token :string +# authors_github_directory :string default("authors") +# name :string +# posts_github_directory :string default("posts") +# programs_github_directory :string default("programs") +# repository :string +# research_articles_github_directory :string default("articles") +# research_volumes_github_directory :string default("volumes") +# staff_github_directory :string default("staff") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid +# university_id :uuid not null # # Indexes # diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index b8c1f9a79f47a0687f1b6ec45bfc1e43389db7cc..e923cf9238ae1e37393acae9f25969c265deb41a 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -56,7 +56,11 @@ class Communication::Website::Menu::Item < ApplicationRecord news: 40, news_category: 41, news_article: 42, - staff: 50 + staff: 50, + research_volumes: 60, + research_volume: 61, + research_articles: 62, + research_article: 63 }, _prefix: :kind validates :title, presence: true @@ -81,6 +85,14 @@ class Communication::Website::Menu::Item < ApplicationRecord target = "/#{website.posts_github_directory}" when 'staff' target = "/#{website.staff_github_directory}" + when 'research_volumes' + target = "/#{website.research_volumes_github_directory}" + when 'research_volume' + target = "/#{website.research_volumes_github_directory}#{about.path}" + when 'research_articles' + target = "/#{website.research_articles_github_directory}" + when 'research_article' + target = "/#{website.research_articles_github_directory}#{about.path}" when 'blank' target = '' else @@ -110,7 +122,9 @@ class Communication::Website::Menu::Item < ApplicationRecord end def has_about? - kind_page? || kind_program? || kind_news_category? || kind_news_article? + kind_page? || kind_program? || + kind_news_category? || kind_news_article? || + kind_research_volume? || kind_research_article? end def sync_menu diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb index c104183822667f6e0343362c5289bb1e50e5bac4..79bae2de7c73ba8329426f3b928024439fbbc74f 100644 --- a/app/models/communication/website/with_abouts.rb +++ b/app/models/communication/website/with_abouts.rb @@ -45,7 +45,11 @@ module Communication::Website::WithAbouts about_school? ? about.programs : Education::Program.none end - def articles + def research_volumes + about_journal? ? about.volumes : Research::Journal::Volume.none + end + + def research_articles about_journal? ? about.articles : Research::Journal::Article.none end @@ -58,8 +62,8 @@ module Communication::Website::WithAbouts people += about.university_people_through_administrators people += about.university_people_through_administrators.map(&:administrator) elsif about_journal? - people += articles.collect(&:researchers).flatten - people += articles.collect(&:researchers).flatten.map(&:researcher) + people += research_articles.collect(&:researchers).flatten + people += research_articles.collect(&:researchers).flatten.map(&:researcher) end end people.uniq.compact diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index ca553be57329cd12042f94c559510be3108e8e8c..ed1248780e9f4944ec70e318a77074d8371c1860 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -68,6 +68,10 @@ class Research::Journal::Article < ApplicationRecord "#{ title }" end + def path + "/#{slug}" + end + protected def last_ordered_element diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 328ded75e988538c46d829ce930f25825a8b6060..c80b3af6bea8a47bfe72c462c384d3a439792c5e 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -60,7 +60,7 @@ class Research::Journal::Volume < ApplicationRecord end def path - "#{published_at&.year}/#{slug}" if published_at + "/#{published_at&.year}/#{slug}" if published_at end def to_s diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index f1b7341ad36fad9dcc90a6d001d2b45ee1eca4ab..b1e89c077d59390868c7db49af3595b2eaef53da 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -36,7 +36,7 @@ class University::Person::Researcher < University::Person end def for_website?(website) - is_researcher && website.about_journal? && website.articles + is_researcher && website.about_journal? && website.research_articles .joins(:researchers) .where(university_people: { id: id }) .any? diff --git a/app/views/admin/communication/website/menu/items/_form.html.erb b/app/views/admin/communication/website/menu/items/_form.html.erb index 44ccf48546d8c00069d35301ad181c62dc048a14..0e9e61ee6e563fee968cc1150fd0802e5785b929 100644 --- a/app/views/admin/communication/website/menu/items/_form.html.erb +++ b/app/views/admin/communication/website/menu/items/_form.html.erb @@ -28,6 +28,10 @@ about_collection = collection_tree(@website.categories) elsif item.kind_news_article? about_collection = @website.posts.ordered.map { |e| { label: e.to_s, id: e.id } } + elsif item.kind_research_volume? + about_collection = @website.research_volumes.ordered.map { |e| { label: e.to_s, id: e.id } } + elsif item.kind_research_article? + about_collection = @website.research_articles.ordered.map { |e| { label: e.to_s, id: e.id } } end else about_collection = [] diff --git a/app/views/admin/communication/website/menu/items/kind_switch.js.erb b/app/views/admin/communication/website/menu/items/kind_switch.js.erb index e883ff32bdcc7dc7ea174b8527d257b46aec8161..9632dd52f7a6eda8535dc27f91792aa0541377f2 100644 --- a/app/views/admin/communication/website/menu/items/kind_switch.js.erb +++ b/app/views/admin/communication/website/menu/items/kind_switch.js.erb @@ -44,6 +44,22 @@ function hideAbout() { end %> displayAbout('Communication::Website::Post', "<%= j(raw(options.join(''))) %>"); +<% elsif @kind == 'research_volume' %> + <% + options = ['<option value="" label=" "></option>'] + @website.research_volumes.ordered.each do |volume| + options << "<option value=\"#{volume.id}\">#{volume.to_s}</option>" + end + %> + displayAbout('Research::Journal::Volume', "<%= j(raw(options.join(''))) %>"); +<% elsif @kind == 'research_article' %> + <% + options = ['<option value="" label=" "></option>'] + @website.research_articles.ordered.each do |article| + options << "<option value=\"#{article.id}\">#{article.to_s}</option>" + end + %> + displayAbout('Research::Journal::Article', "<%= j(raw(options.join(''))) %>"); <% else %> $('.js-url-field').addClass('d-none'); hideAbout(); diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index 9643dfbfe94c1db36d9453928a31228b9677c11b..0b2a65e53b3727248e894c8551de8edfd3eb858b 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -40,6 +40,8 @@ <%= f.input :authors_github_directory %> <%= f.input :posts_github_directory %> <%= f.input :programs_github_directory %> + <%= f.input :research_articles_github_directory %> + <%= f.input :research_volumes_github_directory %> <%= f.input :staff_github_directory %> </div> </div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 7c289b1bd6d6fb0c0b189f7e533e0374dccd8365..a79392d8f92f56e20742ddcd08cb4d2631e00350 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -45,6 +45,8 @@ en: name: Name posts_github_directory: Posts' GitHub directory programs_github_directory: Programs' GitHub directory + research_articles_github_directory: Research articles' GitHub directory + research_volumes_github_directory: Research volumes' GitHub directory staff_github_directory: Staff's GitHub directory url: URL communication/website/author: @@ -141,5 +143,9 @@ en: page: Specific Page program: Specific program programs: Programs index + research_article: Specific research article + research_articles: Research articles index + research_volume: Specific research volume + research_volumes: Research volumes index staff: Staff url: URL diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 0309086e178160ac68e72fc5425032971cd09a9a..9204e1a67c961b231d9003ede7a7fcf4aa23a0b7 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -42,6 +42,8 @@ fr: name: Nom posts_github_directory: Dossier GitHub des actualités programs_github_directory: Dossier GitHub des formations + research_articles_github_directory: Dossier GitHub des articles de recherche + research_volumes_github_directory: Dossier GitHub des volumes de recherche staff_github_directory: Dossier GitHub de l'équipe url: URL communication/website/category: @@ -131,5 +133,9 @@ fr: page: Page spécifique program: Formation spécifique programs: Index des formations + research_article: Article de recherche spécifique + research_articles: Index des articles de recherche + research_volume: Volume de recherche spécifique + research_volumes: Index des volumes de recherche staff: Équipe url: URL diff --git a/db/migrate/20220113155300_add_research_github_directories_to_communication_websites.rb b/db/migrate/20220113155300_add_research_github_directories_to_communication_websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..3534251f1929313478088130eed88d6ccdd79d06 --- /dev/null +++ b/db/migrate/20220113155300_add_research_github_directories_to_communication_websites.rb @@ -0,0 +1,6 @@ +class AddResearchGithubDirectoriesToCommunicationWebsites < ActiveRecord::Migration[6.1] + def change + add_column :communication_websites, :research_volumes_github_directory, :string, default: 'volumes' + add_column :communication_websites, :research_articles_github_directory, :string, default: 'articles' + end +end diff --git a/db/schema.rb b/db/schema.rb index 44cbf87b63419edbf53d97ac4f855275e7f098b5..4d1f21c9a468994f7ee5b44e58e3d4bf999989ac 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_01_12_085221) do +ActiveRecord::Schema.define(version: 2022_01_13_155300) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -327,6 +327,8 @@ ActiveRecord::Schema.define(version: 2022_01_12_085221) do t.string "posts_github_directory", default: "posts" t.string "programs_github_directory", default: "programs" t.string "staff_github_directory", default: "staff" + t.string "research_volumes_github_directory", default: "volumes" + t.string "research_articles_github_directory", default: "articles" t.index ["about_type", "about_id"], name: "index_communication_websites_on_about" t.index ["university_id"], name: "index_communication_websites_on_university_id" end