Skip to content
Snippets Groups Projects
Unverified Commit c9e5bd2f authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge branch 'main' into fix-backlinks

parents 7c4605b5 58b65ae9
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 47 deletions
...@@ -44,7 +44,7 @@ gem "i18n_date_range" ...@@ -44,7 +44,7 @@ gem "i18n_date_range"
gem "image_processing" gem "image_processing"
gem "jbuilder" gem "jbuilder"
gem "jquery-rails" gem "jquery-rails"
gem "jquery-ui-rails", "~> 6.0.1" gem "jquery-ui-rails", git: "https://github.com/jquery-ui-rails/jquery-ui-rails.git", tag: "v7.0.0"
gem "kamifusen"#, path: "../kamifusen" gem "kamifusen"#, path: "../kamifusen"
gem "kaminari" gem "kaminari"
gem "leaflet-rails" gem "leaflet-rails"
......
GIT
remote: https://github.com/jquery-ui-rails/jquery-ui-rails.git
revision: 413265e81f790f795239e07e7e25e01429b2f18d
tag: v7.0.0
specs:
jquery-ui-rails (7.0.0)
railties (>= 3.2.16)
GIT GIT
remote: https://github.com/noesya/summernote-rails.git remote: https://github.com/noesya/summernote-rails.git
revision: 32fd182c929cdcacaa6e3bd3569871bd025fa669 revision: 32fd182c929cdcacaa6e3bd3569871bd025fa669
...@@ -8,9 +16,9 @@ GIT ...@@ -8,9 +16,9 @@ GIT
GIT GIT
remote: https://github.com/noesya/two_factor_authentication.git remote: https://github.com/noesya/two_factor_authentication.git
revision: 16fb01e5731c2b08ef0885134e5e0bdec2ed87ff revision: a3505e961baf7cb0bf68bb3a6349aeaf5e1baf97
specs: specs:
two_factor_authentication (4.1.1) two_factor_authentication (4.1.2)
devise devise
encryptor encryptor
rails (>= 3.1.1) rails (>= 3.1.1)
...@@ -112,20 +120,20 @@ GEM ...@@ -112,20 +120,20 @@ GEM
autoprefixer-rails (10.4.16.0) autoprefixer-rails (10.4.16.0)
execjs (~> 2) execjs (~> 2)
aws-eventstream (1.3.0) aws-eventstream (1.3.0)
aws-partitions (1.859.0) aws-partitions (1.863.0)
aws-sdk-core (3.188.0) aws-sdk-core (3.190.0)
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0) aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5) aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1) jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.73.0) aws-sdk-kms (1.74.0)
aws-sdk-core (~> 3, >= 3.188.0) aws-sdk-core (~> 3, >= 3.188.0)
aws-sigv4 (~> 1.1) aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.140.0) aws-sdk-s3 (1.141.0)
aws-sdk-core (~> 3, >= 3.188.0) aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-kms (~> 1) aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6) aws-sigv4 (~> 1.8)
aws-sigv4 (1.7.0) aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0) base64 (0.2.0)
bcrypt (3.1.20) bcrypt (3.1.20)
...@@ -248,7 +256,7 @@ GEM ...@@ -248,7 +256,7 @@ GEM
ffi (1.16.3) ffi (1.16.3)
figaro (1.2.0) figaro (1.2.0)
thor (>= 0.14.0, < 2) thor (>= 0.14.0, < 2)
font-awesome-sass (6.4.2) font-awesome-sass (6.5.1)
sassc (~> 2.0) sassc (~> 2.0)
front_matter_parser (1.0.1) front_matter_parser (1.0.1)
geo_calc (0.7.8) geo_calc (0.7.8)
...@@ -298,7 +306,7 @@ GEM ...@@ -298,7 +306,7 @@ GEM
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3) ruby-vips (>= 2.0.17, < 3)
io-console (0.6.0) io-console (0.6.0)
irb (1.9.1) irb (1.10.1)
rdoc rdoc
reline (>= 0.3.8) reline (>= 0.3.8)
jbuilder (2.11.5) jbuilder (2.11.5)
...@@ -309,9 +317,7 @@ GEM ...@@ -309,9 +317,7 @@ GEM
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1) json (2.7.1)
railties (>= 3.2.16)
json (2.6.3)
jwt (2.7.1) jwt (2.7.1)
kamifusen (1.11.2) kamifusen (1.11.2)
image_processing image_processing
...@@ -369,7 +375,7 @@ GEM ...@@ -369,7 +375,7 @@ GEM
nesty (1.0.2) nesty (1.0.2)
net-http (0.4.0) net-http (0.4.0)
uri uri
net-imap (0.4.6) net-imap (0.4.7)
date date
net-protocol net-protocol
net-pop (0.1.2) net-pop (0.1.2)
...@@ -378,7 +384,7 @@ GEM ...@@ -378,7 +384,7 @@ GEM
timeout timeout
net-smtp (0.4.0) net-smtp (0.4.0)
net-protocol net-protocol
nio4r (2.6.1) nio4r (2.7.0)
nokogiri (1.15.5-arm64-darwin) nokogiri (1.15.5-arm64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.15.5-x86_64-darwin) nokogiri (1.15.5-x86_64-darwin)
...@@ -405,7 +411,7 @@ GEM ...@@ -405,7 +411,7 @@ GEM
omniauth-saml (2.1.0) omniauth-saml (2.1.0)
omniauth (~> 2.0) omniauth (~> 2.0)
ruby-saml (~> 1.12) ruby-saml (~> 1.12)
open-uri (0.4.0) open-uri (0.4.1)
stringio stringio
time time
uri uri
...@@ -428,7 +434,7 @@ GEM ...@@ -428,7 +434,7 @@ GEM
rack (>= 1.2.0) rack (>= 1.2.0)
rack-protection (3.1.0) rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4) rack (~> 2.2, >= 2.2.4)
rack-session (1.0.1) rack-session (1.0.2)
rack (< 3) rack (< 3)
rack-test (2.1.0) rack-test (2.1.0)
rack (>= 1.3) rack (>= 1.3)
...@@ -474,10 +480,10 @@ GEM ...@@ -474,10 +480,10 @@ GEM
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
rdoc (6.6.0) rdoc (6.6.1)
psych (>= 4.0.0) psych (>= 4.0.0)
regexp_parser (2.8.2) regexp_parser (2.8.3)
reline (0.4.0) reline (0.4.1)
io-console (~> 0.5) io-console (~> 0.5)
requests (1.0.2) requests (1.0.2)
require_all (3.0.0) require_all (3.0.0)
...@@ -654,7 +660,7 @@ DEPENDENCIES ...@@ -654,7 +660,7 @@ DEPENDENCIES
image_processing image_processing
jbuilder jbuilder
jquery-rails jquery-rails
jquery-ui-rails (~> 6.0.1) jquery-ui-rails!
kamifusen kamifusen
kaminari kaminari
leaflet-rails leaflet-rails
......
...@@ -10,8 +10,8 @@ $(function () { ...@@ -10,8 +10,8 @@ $(function () {
type: 'POST', type: 'POST',
url: target, url: target,
data: { data: {
objectId: id, 'object_id': id,
objectType: type 'object_type': type
} }
}).done(function () { }).done(function () {
location.reload(); location.reload();
......
/*global $, jQuery */
/* This allow ujs requests to automatically inject nonce */
$(function () {
'use strict';
$.ajaxSetup({
converters: {
'text script': function (text) {
jQuery.globalEval(text, { nonce: $('meta[name="csp-nonce"]').attr('content') });
return text;
}
}
});
});
\ No newline at end of file
...@@ -9,6 +9,5 @@ ...@@ -9,6 +9,5 @@
//= require cropperjs/dist/cropper //= require cropperjs/dist/cropper
//= require jquery-cropper/dist/jquery-cropper //= require jquery-cropper/dist/jquery-cropper
//= require_self //= require_self
//= require_tree ./admin/plugins
window.osuny = {}; window.osuny = {};
//= require leaflet/dist/leaflet.js
\ No newline at end of file
.sidebar-icon
min-width: 30px
\ No newline at end of file
@import 'leaflet/dist/leaflet'
\ No newline at end of file
...@@ -20,7 +20,12 @@ class Admin::Communication::Blocks::HeadingsController < Admin::Communication::B ...@@ -20,7 +20,12 @@ class Admin::Communication::Blocks::HeadingsController < Admin::Communication::B
end end
def new def new
@heading.about = PolymorphicObjectFinder.find params, :about @heading.about = PolymorphicObjectFinder.find(
params,
key: :about,
university: current_university,
only: Communication::Block::Heading.permitted_about_types
)
breadcrumb breadcrumb
end end
......
...@@ -18,7 +18,12 @@ class Admin::Communication::BlocksController < Admin::Communication::Application ...@@ -18,7 +18,12 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
end end
def new def new
@block.about = PolymorphicObjectFinder.find params, :about @block.about = PolymorphicObjectFinder.find(
params,
key: :about,
university: current_university,
only: Communication::Block.permitted_about_types
)
breadcrumb breadcrumb
end end
...@@ -61,12 +66,17 @@ class Admin::Communication::BlocksController < Admin::Communication::Application ...@@ -61,12 +66,17 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
return unless request.xhr? return unless request.xhr?
cookies.signed[Communication::Block::BLOCK_COPY_COOKIE] = { cookies.signed[Communication::Block::BLOCK_COPY_COOKIE] = {
value: params[:id], value: params[:id],
path: '/admin' path: '/admin'
} }
end end
def paste def paste
about = PolymorphicObjectFinder.find(params, :about) about = PolymorphicObjectFinder.find(
params,
key: :about,
university: current_university,
only: Communication::Block.permitted_about_types
)
# On réattribue à @block pour bénéficier du calcul dans about_path # On réattribue à @block pour bénéficier du calcul dans about_path
@block = @block.paste(about) @block = @block.paste(about)
cookies.delete(Communication::Block::BLOCK_COPY_COOKIE, path: '/admin') cookies.delete(Communication::Block::BLOCK_COPY_COOKIE, path: '/admin')
......
...@@ -13,8 +13,12 @@ class Admin::Communication::ContentsController < Admin::Communication::Applicati ...@@ -13,8 +13,12 @@ class Admin::Communication::ContentsController < Admin::Communication::Applicati
protected protected
def load_about def load_about
@about = PolymorphicObjectFinder.find(params, :about) @about = PolymorphicObjectFinder.find(
raise_403_unless @about.university == current_university params,
key: :about,
university: current_university,
only: Communication::Block.permitted_about_types
)
raise_403_unless can?(:edit, @about) raise_403_unless can?(:edit, @about)
end end
end end
\ No newline at end of file
...@@ -53,8 +53,11 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication ...@@ -53,8 +53,11 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication
protected protected
def load_object def load_object
object_type = params[:objectType] @object = PolymorphicObjectFinder.find(
object_id = params[:objectId] params,
@object = object_type.constantize.find object_id key: :object,
university: current_university,
only: Communication::Extranet::Connection.permitted_about_types
)
end end
end end
...@@ -134,9 +134,12 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We ...@@ -134,9 +134,12 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We
protected protected
def load_object def load_object
object_type = params[:objectType] @object = PolymorphicObjectFinder.find(
object_id = params[:objectId] params,
@object = object_type.constantize.find object_id key: :object,
university: current_university,
only: [@page.class.direct_connection_permitted_about_type]
)
end end
def breadcrumb def breadcrumb
......
...@@ -2,7 +2,12 @@ class Admin::Communication::Websites::PermalinksController < Admin::Communicatio ...@@ -2,7 +2,12 @@ class Admin::Communication::Websites::PermalinksController < Admin::Communicatio
def create def create
@path = params['communication_website_permalink']['path'] @path = params['communication_website_permalink']['path']
@about = PolymorphicObjectFinder.find(params, :about) @about = PolymorphicObjectFinder.find(
params,
key: :about,
university: current_university,
only: Communication::Website::Permalink.permitted_about_types
)
@permalink = @about.add_redirection(@path) @permalink = @about.add_redirection(@path)
end end
end end
\ No newline at end of file
...@@ -21,9 +21,12 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -21,9 +21,12 @@ class Admin::UsersController < Admin::ApplicationController
def favorite def favorite
operation = params[:operation] operation = params[:operation]
id = params[:about_id] about = PolymorphicObjectFinder.find(
type = params[:about_type] params,
about = type.constantize.find id key: :about,
university: current_university,
only: User::Favorite.permitted_about_types
)
if operation == 'add' if operation == 'add'
current_user.add_favorite(about) current_user.add_favorite(about)
else else
......
class Server::WebsitesController < Server::ApplicationController class Server::WebsitesController < Server::ApplicationController
before_action :load_website, except: :index before_action :load_websites, only: [:index, :manage_versions, :update_all_themes]
before_action :load_website, except: [:index, :manage_versions, :update_all_themes]
has_scope :for_theme_version has_scope :for_theme_version
has_scope :for_production has_scope :for_production
...@@ -8,10 +9,22 @@ class Server::WebsitesController < Server::ApplicationController ...@@ -8,10 +9,22 @@ class Server::WebsitesController < Server::ApplicationController
has_scope :for_updatable_theme has_scope :for_updatable_theme
def index def index
@websites = apply_scopes(Communication::Website.all).ordered
breadcrumb breadcrumb
end end
def manage_versions
load_filters
breadcrumb
add_breadcrumb "Gestion des versions"
end
def update_all_themes
@websites.find_each do |website|
website.clean_and_rebuild
end
redirect_back(fallback_location: manage_versions_server_websites_path, notice: t('server_admin.websites.update_all_themes_notice'))
end
def sync_theme_version def sync_theme_version
@website.get_current_theme_version! @website.get_current_theme_version!
end end
...@@ -38,6 +51,10 @@ class Server::WebsitesController < Server::ApplicationController ...@@ -38,6 +51,10 @@ class Server::WebsitesController < Server::ApplicationController
add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path
end end
def load_websites
@websites = apply_scopes(Communication::Website.all).ordered
end
def load_website def load_website
@website = Communication::Website.find params[:id] @website = Communication::Website.find params[:id]
end end
......
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
def self.models_with_concern(concern)
descendants.select { |model|
model.included_modules.include?(concern)
}
end
def self.model_names_with_concern(concern)
models_with_concern(concern).map(&:name)
end
end end
...@@ -102,6 +102,10 @@ class Communication::Block < ApplicationRecord ...@@ -102,6 +102,10 @@ class Communication::Block < ApplicationRecord
before_save :attach_template_blobs before_save :attach_template_blobs
before_validation :set_university_and_website_from_about, on: :create before_validation :set_university_and_website_from_about, on: :create
def self.permitted_about_types
ApplicationRecord.model_names_with_concern(WithBlocks)
end
# When we set data from json, we pass it to the template. # When we set data from json, we pass it to the template.
# The json we save is first sanitized and prepared by the template. # The json we save is first sanitized and prepared by the template.
def data=(value) def data=(value)
......
class Communication::Block::Component::Text < Communication::Block::Component::Base class Communication::Block::Component::Text < Communication::Block::Component::Base
def data=(value) def data=(value)
@data = Osuny::Sanitizer.sanitize value, 'string' @data = Osuny::Sanitizer.sanitize value, 'text'
end end
def full_text def full_text
......
...@@ -51,6 +51,10 @@ class Communication::Block::Heading < ApplicationRecord ...@@ -51,6 +51,10 @@ class Communication::Block::Heading < ApplicationRecord
before_validation :compute_level before_validation :compute_level
def self.permitted_about_types
ApplicationRecord.model_names_with_concern(WithBlocks)
end
def references def references
[about] [about]
end end
......
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