Skip to content
Snippets Groups Projects
Commit 942f6591 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Merge branch 'main' into pure_funk

parents 55a09e27 22f49ae5
No related branches found
No related tags found
No related merge requests found
Showing
with 215 additions and 209 deletions
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
......@@ -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)
......
......@@ -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
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
......@@ -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
......
class Server::ApplicationController < ApplicationController
layout 'server/layouts/application'
include Admin::Filterable
before_action :authenticate_user!, :ensure_user_if_server_admin
protected
......
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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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,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
......
......@@ -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
......
......@@ -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
......@@ -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
#
......
......@@ -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
#
......
......@@ -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
#
......
......@@ -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
#
......
......@@ -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
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment