diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index edd21493eaff454a34c888c26d3db88747f97208..44877c2ca6c1bad74748e8d284e6308881751e23 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -1,7 +1,7 @@ class Admin::ApplicationController < ApplicationController layout 'admin/layouts/application' - before_action :load_filters, only: :index + include Admin::Filterable def set_theme current_user.update_column :admin_theme, params[:theme] @@ -27,11 +27,5 @@ class Admin::ApplicationController < ApplicationController : add_breadcrumb(t('create')) end - def load_filters - @filters = [] - filter_class_name = "::Filters::#{self.class.to_s.gsub('Controller', '')}" - # filter_class will be nil if filter does not exist - filter_class = filter_class_name.safe_constantize - @filters = filter_class.new(current_user).list unless filter_class.nil? - end + end diff --git a/app/controllers/admin/communication/websites/posts/curations_controller.rb b/app/controllers/admin/communication/websites/posts/curations_controller.rb index 98bb804cfcd3a1f2ad685d67e1337c19681ee6d9..111b201ca983bcdff52ddcaab87b9036a5123c46 100644 --- a/app/controllers/admin/communication/websites/posts/curations_controller.rb +++ b/app/controllers/admin/communication/websites/posts/curations_controller.rb @@ -4,7 +4,7 @@ class Admin::Communication::Websites::Posts::CurationsController < Admin::Commun end def create - @curator = Curator.new @website, current_user, curation_params[:url] + @curator = Curator.new @website, current_user, current_website_language, curation_params[:url] if @curator.valid? redirect_to [:admin, @curator.post], notice: t('admin.successfully_created_html', model: @curator.post.to_s) diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 722d408593fb4cdf649664b1dde842fcb15286db..d83628439f6b2d87ab09005347ef20cd8f185d65 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -77,12 +77,6 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: protected - def breadcrumb - super - add_breadcrumb Communication::Website.model_name.human(count: 2), admin_communication_websites_path - breadcrumb_for @website - end - def website_params attribute_names = [ :name, :url, :repository, :access_token, :about_type, :about_id, :in_production, @@ -95,7 +89,7 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: def default_url_options options = {} - options[:lang] = current_website_language.iso_code if @website.present? + options[:lang] = current_website_language.iso_code if @website&.persisted? options end end diff --git a/app/controllers/concerns/admin/filterable.rb b/app/controllers/concerns/admin/filterable.rb new file mode 100644 index 0000000000000000000000000000000000000000..db61a29a4e763eb5bb2f23b9462e06056e9bffcc --- /dev/null +++ b/app/controllers/concerns/admin/filterable.rb @@ -0,0 +1,18 @@ +module Admin::Filterable + extend ActiveSupport::Concern + + included do + before_action :load_filters, only: :index + end + + protected + + def load_filters + @filters = [] + filter_class_name = "::Filters::#{self.class.to_s.gsub('Controller', '')}" + # filter_class will be nil if filter does not exist + filter_class = filter_class_name.safe_constantize + @filters = filter_class.new(current_user).list unless filter_class.nil? + end + +end diff --git a/app/controllers/concerns/admin/translatable.rb b/app/controllers/concerns/admin/translatable.rb index fe8a43c8bf88f18b89ea1762c979b59b37b8b546..429d34711d86130e045d67c844dd11e7f079804e 100644 --- a/app/controllers/concerns/admin/translatable.rb +++ b/app/controllers/concerns/admin/translatable.rb @@ -17,7 +17,7 @@ module Admin::Translatable redirect_to_translation(translation) end - def redirect_to_translation + def redirect_to_translation(translation) if ['edit', 'update'].include?(action_name) || translation.newly_translated # Safety net on update action if called on wrong language # There's an attribute accessor named "newly_translated" that we set to true diff --git a/app/controllers/server/application_controller.rb b/app/controllers/server/application_controller.rb index 3966163c2dbd6ae8361e2caf16691c4fa8f035dc..15ed3b9a9354c93889e6ee07cd0c0feef2ad220f 100644 --- a/app/controllers/server/application_controller.rb +++ b/app/controllers/server/application_controller.rb @@ -1,6 +1,8 @@ class Server::ApplicationController < ApplicationController layout 'server/layouts/application' + include Admin::Filterable + before_action :authenticate_user!, :ensure_user_if_server_admin protected diff --git a/app/controllers/server/websites_controller.rb b/app/controllers/server/websites_controller.rb index f61e76457f86ad025d057f0d98e3a6dc68d023bc..a318cc32a881ca74c0241bf73b81e6160e97ef5c 100644 --- a/app/controllers/server/websites_controller.rb +++ b/app/controllers/server/websites_controller.rb @@ -1,7 +1,10 @@ class Server::WebsitesController < Server::ApplicationController + has_scope :for_theme_version + has_scope :for_search_term + def index - @websites = Communication::Website.all.ordered + @websites = apply_scopes(Communication::Website.all).ordered breadcrumb add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path end @@ -9,7 +12,6 @@ class Server::WebsitesController < Server::ApplicationController def refresh @website = Communication::Website.find params[:id] @website.get_current_theme_version! - redirect_back fallback_location: server_websites_path end -end \ No newline at end of file +end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index a750fc64799da4e044e784fcbb69cdc2d4238fff..52a48b87fc60d8ecb08e652ddf6c199fdd42cbf7 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null @@ -66,6 +66,7 @@ class Communication::Website < ApplicationRecord scope :ordered, -> { order(:name) } scope :in_production, -> { where(in_production: true) } + scope :for_theme_version, -> (version) { where(theme_version: version) } scope :for_search_term, -> (term) { where(" unaccent(communication_websites.name) ILIKE unaccent(:term) OR diff --git a/app/models/communication/website/configs/default_languages.rb b/app/models/communication/website/configs/default_languages.rb index 59fe8171043cb2553e2140e62078890c1f926e80..cd5602c6af1c9bf7e055f79f7456961cb1f97cdb 100644 --- a/app/models/communication/website/configs/default_languages.rb +++ b/app/models/communication/website/configs/default_languages.rb @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/default_permalinks.rb b/app/models/communication/website/configs/default_permalinks.rb index 287cc69e45154237b21677063f1b003ccfba144c..f3d35ca03d71b003f36952e923e912ee85d8b5ee 100644 --- a/app/models/communication/website/configs/default_permalinks.rb +++ b/app/models/communication/website/configs/default_permalinks.rb @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/development_config.rb b/app/models/communication/website/configs/development_config.rb index d3b15c0ecb92c2bfdf2720b3fd61d1ec973026e2..e9f4d3e2085f903d4f38e7a0747483da81bcc632 100644 --- a/app/models/communication/website/configs/development_config.rb +++ b/app/models/communication/website/configs/development_config.rb @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/configs/production_config.rb b/app/models/communication/website/configs/production_config.rb index c6eb64a6533cb745c5086090a09880ac823395fd..b9290cbe22e7a9c16a52062ea82eac515a4f7e00 100644 --- a/app/models/communication/website/configs/production_config.rb +++ b/app/models/communication/website/configs/production_config.rb @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/communication/website/page/with_path.rb b/app/models/communication/website/page/with_path.rb index 838522b21787f90f29ef9973d897afa901352445..1444d93b5081e35ad6ba2c261550c109b26a5a08 100644 --- a/app/models/communication/website/page/with_path.rb +++ b/app/models/communication/website/page/with_path.rb @@ -66,11 +66,11 @@ module Communication::Website::Page::WithPath end def slug_must_be_present - errors.add(:slug, ActiveRecord::Errors.default_error_messages[:absent]) if slug.blank? + errors.add(:slug, :absent) if slug.blank? end def slug_must_be_unique - errors.add(:slug, ActiveRecord::Errors.default_error_messages[:taken]) if slug_unavailable?(slug) + errors.add(:slug, :taken) if slug_unavailable?(slug) end def slug_must_have_proper_format diff --git a/app/models/communication/website/with_menus.rb b/app/models/communication/website/with_menus.rb index 256f7343ff18133830966dd02c807762e30192a6..aa377e88a93ca2629adda552d43c160b5df6bf6c 100644 --- a/app/models/communication/website/with_menus.rb +++ b/app/models/communication/website/with_menus.rb @@ -74,7 +74,7 @@ module Communication::Website::WithMenus def find_or_create_menu(identifier) menu = menus.where(identifier: identifier, university: university, language: default_language).first_or_initialize do |menu| - menu.title = t("communication.menus.default_title.#{identifier}") + menu.title = I18n.t("communication.menus.default_title.#{identifier}") end unless menu.persisted? menu.save diff --git a/app/models/concerns/with_slug.rb b/app/models/concerns/with_slug.rb index f7042b19fc7f9514d5bb80d7c8e831a65dcb051e..7f3dc552cff3b16833bffc882a6d5c3dde7fae41 100644 --- a/app/models/concerns/with_slug.rb +++ b/app/models/concerns/with_slug.rb @@ -40,7 +40,7 @@ module WithSlug end def slug_must_be_unique - errors.add(:slug, ActiveRecord::Errors.default_error_messages[:taken]) if slug_unavailable?(slug) + errors.add(:slug, :taken) if slug_unavailable?(slug) end end end diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 5706c62d7ee1d8248beaa12e04a015804be123f9..55a5bbfcbbe41b83b80522de8ee226a6658b8ef2 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index 14c3f802b06c8aa3f388e645e69a1fe777db5074..0e2fcd0e1efbd1400755ce5eee1d88dbf43451c7 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/alumnus.rb b/app/models/university/person/alumnus.rb index 0208d188ba5d6a699f8abaa9f912492b51344b31..9d0679e9203a30413d4d9e7ebfbe9d0ac818494d 100644 --- a/app/models/university/person/alumnus.rb +++ b/app/models/university/person/alumnus.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index 496f29babdd7ef9353b0ae1bb7f7a99b36be63a0..a19bc5d64fb2f6f6cadc4f7f19e8f6c10be85611 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 72e633ff0e632f4732154e7071d8b29ced18bb28..70847b670240e2ba561b80c85c23a265ad671cbe 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index 00f43010043f8e5c854091dbc9fcdc1c0e80bc84..48cf9b6ad66ed27815450df7384f834d2a3d19a8 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/services/curator.rb b/app/services/curator.rb index e00294534042c9eab0d457130569b7ca4a65b832..4f7c5042800995657d8cb46f6614626fb6e8a485 100644 --- a/app/services/curator.rb +++ b/app/services/curator.rb @@ -1,9 +1,10 @@ class Curator - attr_reader :website, :user, :url, :post + attr_reader :website, :user, :language, :url, :post - def initialize(website, user, url) + def initialize(website, user, language, url) @website = website @user = user + @language = language @url = url create_post! attach_image! unless page.image.blank? @@ -22,7 +23,8 @@ class Curator title: page.title, slug: page.title.parameterize, author: @user.person, - published_at: Time.now + published_at: Time.now, + language_id: @language.id ) @chapter = @post.blocks.create( university: website.university, diff --git a/app/services/filters/server/websites.rb b/app/services/filters/server/websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..120ed5e58546f251e463ab8e823da91c00b669ad --- /dev/null +++ b/app/services/filters/server/websites.rb @@ -0,0 +1,11 @@ +module Filters + class Server::Websites < Filters::Base + def initialize(user) + super + add_search + add :for_theme_version, + ::Communication::Website.all.pluck(:theme_version).uniq.sort, + 'Filtrer par version du thème' + end + end +end diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index ce585ca206e8ceadc9041fd370f92e82e5fbc018..288e6602ceab46ef1e2c621fea2c4ff6dc6f58dc 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,8 +1,8 @@ <% content_for :title, "#{User.model_name.human(count: 2)} (#{@users.total_count})" %> -<%= render 'admin/application/filters', - current_path: admin_users_path, - filters: @filters if @filters.any? %> +<%= render 'admin/application/filters', + current_path: admin_users_path, + filters: @filters if @filters.any? %> <div class="table-responsive"> <table class="<%= table_classes %>"> diff --git a/app/views/server/websites/_list.html.erb b/app/views/server/websites/_list.html.erb index 743c78fd7fe549827b835feba07c8f8c09ee8c71..dab2389a5eebec82b2fec25d201cd130cc7ed60b 100644 --- a/app/views/server/websites/_list.html.erb +++ b/app/views/server/websites/_list.html.erb @@ -13,7 +13,7 @@ </thead> <tbody> <% websites.ordered.each do |website| %> - <tr> + <tr id="website-<%= website.id %>"> <td><%= link_to website.name, admin_communication_website_url(website, host: website.university.url), target: :_blank %></td> <td><%= I18n.t("activerecord.attributes.communication/website.about_#{website.about_type}") %></td> <td> @@ -22,12 +22,12 @@ <span class="badge bg-success">Prod</span> <% end %> </td> - <td><%= link_to website.theme_version, website.theme_version_url, target: :_blank if website.theme_version_url.present? %></td> + <td class="js-version"><%= link_to website.theme_version, website.theme_version_url, target: :_blank if website.theme_version_url.present? %></td> <td><%= link_to website.university, [:server, website.university] %></td> <td><%= l website.created_at.to_date %></td> - <td><%= link_to "Sync version", refresh_server_website_path(website), method: :post, class: button_classes if website.url.present? %></td> + <td><%= link_to "Sync version", refresh_server_website_path(website), method: :post, remote: true, class: button_classes if website.url.present? %></td> </tr> <% end %> </tbody> </table> -</div> \ No newline at end of file +</div> diff --git a/app/views/server/websites/index.html.erb b/app/views/server/websites/index.html.erb index b3d4a09cca19597789d636548966cadb4aeb2763..32fd7c7a742e28495c9436a523bc83b35cc7c9a4 100644 --- a/app/views/server/websites/index.html.erb +++ b/app/views/server/websites/index.html.erb @@ -2,4 +2,8 @@ <p><%= Communication::Website.in_production.count %> en production</p> -<%= render 'server/websites/list', websites: @websites %> \ No newline at end of file +<%= render 'admin/application/filters', + current_path: server_websites_path, + filters: @filters if @filters.any? %> + +<%= render 'server/websites/list', websites: @websites %> diff --git a/app/views/server/websites/refresh.js.erb b/app/views/server/websites/refresh.js.erb new file mode 100644 index 0000000000000000000000000000000000000000..5e4a1ebd8298c0d7c701ec736c224d555e1be6fb --- /dev/null +++ b/app/views/server/websites/refresh.js.erb @@ -0,0 +1,2 @@ +var column = document.querySelector('#website-<%= @website.id %> .js-version'); +column.innerHTML = "<%= j link_to @website.theme_version, @website.theme_version_url, target: '_blank' if @website.theme_version_url.present? %>"; diff --git a/db/migrate/20230210132818_add_default_value_to_website_theme_version.rb b/db/migrate/20230210132818_add_default_value_to_website_theme_version.rb new file mode 100644 index 0000000000000000000000000000000000000000..e66bdb6c341fdb4cf91712855cc64724b25513e8 --- /dev/null +++ b/db/migrate/20230210132818_add_default_value_to_website_theme_version.rb @@ -0,0 +1,6 @@ +class AddDefaultValueToWebsiteThemeVersion < ActiveRecord::Migration[7.0] + def change + change_column_default :communication_websites, :theme_version, 'NA' + Communication::Website.where(theme_version: nil).update_all(theme_version: 'NA') + end +end diff --git a/db/schema.rb b/db/schema.rb index aae0b24e66c2141859b208683c8c02c248b79239..c146ac356f27bbec7b8ab65b8474035e6f12547a 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[7.0].define(version: 2023_02_03_135355) do +ActiveRecord::Schema[7.0].define(version: 2023_02_10_132818) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -397,7 +397,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do t.string "git_branch" t.boolean "in_production", default: false t.uuid "default_language_id", null: false - t.string "theme_version" + t.string "theme_version", default: "NA" t.index ["about_type", "about_id"], name: "index_communication_websites_on_about" t.index ["default_language_id"], name: "index_communication_websites_on_default_language_id" t.index ["university_id"], name: "index_communication_websites_on_university_id" @@ -577,20 +577,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do t.string "summernote_locale" end - create_table "research_documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "university_id", null: false - t.uuid "university_person_id", null: false - t.string "docid" - t.jsonb "data" - t.string "title" - t.string "url" - t.string "ref" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["university_id"], name: "index_research_documents_on_university_id" - t.index ["university_person_id"], name: "index_research_documents_on_university_person_id" - end - create_table "research_journal_paper_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "journal_id", null: false @@ -796,7 +782,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do t.string "zipcode" t.string "city" t.string "country" - t.string "hal_person_identifier" t.string "mastodon" t.uuid "language_id", null: false t.uuid "original_id" @@ -954,8 +939,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do add_foreign_key "education_schools", "universities" add_foreign_key "imports", "universities" add_foreign_key "imports", "users" - add_foreign_key "research_documents", "universities" - add_foreign_key "research_documents", "university_people" add_foreign_key "research_journal_paper_kinds", "research_journals", column: "journal_id" add_foreign_key "research_journal_paper_kinds", "universities" add_foreign_key "research_journal_papers", "research_journal_paper_kinds", column: "kind_id" diff --git a/test/controllers/server/websites_controller_test.rb b/test/controllers/server/websites_controller_test.rb index aad867f2bf210edc879663d501dba29b97bbc4db..a05c068ebd584e2133d8dafdd5fe095a34569fde 100644 --- a/test/controllers/server/websites_controller_test.rb +++ b/test/controllers/server/websites_controller_test.rb @@ -9,7 +9,7 @@ class Server::WebsitesControllerTest < ActionDispatch::IntegrationTest end def test_refresh - post(refresh_server_website_path(communication_websites(:website_with_github))) - assert_redirected_to(server_websites_path) + post(refresh_server_website_path(communication_websites(:website_with_github)), xhr: true) + assert_response(:success) end end diff --git a/test/fixtures/communication/websites.yml b/test/fixtures/communication/websites.yml index c88335243ca617b01c215a6c42c30c8a0f47c4c6..8f739d38af84415d173df302117170720604e07d 100644 --- a/test/fixtures/communication/websites.yml +++ b/test/fixtures/communication/websites.yml @@ -14,7 +14,7 @@ # repository :string # style :text # style_updated_at :date -# theme_version :string +# theme_version :string default("NA") # url :string # created_at :datetime not null # updated_at :datetime not null diff --git a/test/fixtures/university/people.yml b/test/fixtures/university/people.yml index 4c0df963a5feedca53b12340d9d1b509ab65d3bd..c8c32545e279d6cfb5e84d066c31f4f3f6588c9b 100644 --- a/test/fixtures/university/people.yml +++ b/test/fixtures/university/people.yml @@ -2,42 +2,41 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# hal_person_identifier :string -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# mastodon :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# language_id :uuid not null, indexed -# original_id :uuid indexed -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# language_id :uuid not null, indexed +# original_id :uuid indexed +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes #