sibu 1.0.17 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0881050b04d182c65eeffbad03d9685873c0c19d'
4
- data.tar.gz: 596ab4805391210194ff4ca5ee3526eb535cf175
3
+ metadata.gz: e913afa40651591876a68f2f23dade0fb309c410
4
+ data.tar.gz: bca620a625fdbc2cfd19a536e387f1841587af4a
5
5
  SHA512:
6
- metadata.gz: 33e03744ade338a03c6b16fb327d2675163abe23f4d3ee2f5b3fe58c301fb6573c8409c6007dbf787c58a9d20e7e24391d07f52d8b6ca69912222681d40ce2b8
7
- data.tar.gz: c653ca08088170f1c076d793e1bf14dc7adf62ae849e18a899b9a3cd3ed162b98e1d00958be7ab05865486e7e7c80fe0ba89e848efadb70daee21036602c5db9
6
+ metadata.gz: 492a6fda285b61ed431cbb30c8f61ec9b55e98bb15d69f5671b5c9520bf260caec02b44834a15323650111075d96b0826e76e76ce3df0f18e281ab3f379c212f
7
+ data.tar.gz: 859ccb722dd7fe498ec580bdd3ccb76a7a22c0831865c25299fe3c6af04f8658aa29670b3e839e2c0a9151061dd26ca3e8d4fb5ef911b52c2e59873cf30854d8
@@ -20,11 +20,15 @@ module Sibu
20
20
  p = Sibu::Page.find(@page_id)
21
21
  entity = @entity_type == 'site' ? p.site : p
22
22
  ids = (@section_id.split('|') + @element_id.split('|')).uniq[0...-1]
23
- elt = entity.update_element(*ids, {"id" => @img_id, "src" => @image.file_url(@size.to_sym), "alt" => @image.alt})
24
- if elt.nil?
25
- msg = {alert: "Une erreur s'est produite lors de la mise à jour de l'image."}
23
+ if entity.has_section?(ids.first)
24
+ elt = entity.update_element(*ids, {"id" => @img_id, "src" => @image.file_url(@size.to_sym), "alt" => @image.alt})
25
+ if elt.nil?
26
+ msg = {alert: "Une erreur s'est produite lors de la mise à jour de l'image."}
27
+ else
28
+ msg = {notice: "L'image a bien été mise à jour."}
29
+ end
26
30
  else
27
- msg = {notice: "L'image a bien été mise à jour."}
31
+ msg = {alert: "L'image n'a pas pu être ajoutée à la section."}
28
32
  end
29
33
  redirect_to site_page_edit_content_path(p.site_id, @page_id), msg
30
34
  else
@@ -11,6 +11,8 @@ module Sibu
11
11
  :child_element, :new_section, :create_section, :edit_section,
12
12
  :update_section, :delete_section]
13
13
  before_action :set_online, only: [:show, :edit]
14
+ before_action :check_section, only: [:edit_element, :update_element, :clone_element, :delete_element,
15
+ :child_element, :edit_section, :update_section, :delete_section]
14
16
 
15
17
  skip_before_action Rails.application.config.sibu[:auth_filter], only: [:show]
16
18
 
@@ -197,6 +199,13 @@ module Sibu
197
199
  params.permit!
198
200
  end
199
201
 
202
+ def check_section
203
+ section_id = params[:section_id]
204
+ unless @entity && @entity.has_section?(section_id)
205
+ redirect_to main_app.root_url, alert: "L'opération n'a pas pu aboutir."
206
+ end
207
+ end
208
+
200
209
  def compile_assets
201
210
  Sibu::DynamicStyle.new(params[:site_id]).compile if Rails.env.development? && conf[:custom_styles] && !params[:site_id].blank?
202
211
  end
@@ -131,5 +131,9 @@ module Sibu
131
131
  end
132
132
  node
133
133
  end
134
+
135
+ def has_section?(section_id)
136
+ sections && sections.find {|s| s['id'] == section_id}
137
+ end
134
138
  end
135
139
  end
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.0.17'
2
+ VERSION = '1.0.18'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails