sibu 0.1.11 → 0.1.12

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: 9efa54f95bf9624f3e75050cab00861a3142662b
4
- data.tar.gz: 3d84e0bfbfeb7fefd2c8c6fd4116c3de969dc2c2
3
+ metadata.gz: 9f546bd4008bbe0847d6328ae30fd34f0feb06f8
4
+ data.tar.gz: 9734a6b7db39f25dd1a9de72feeafe551d49d302
5
5
  SHA512:
6
- metadata.gz: 11644aaa295ba8e4f3732ee52328f69384976c24670c46a937405dd2dee498564e0f4b975f8e4090bad6f359afe7f0141df1d08714bcfcb93ca5a9524290aa66
7
- data.tar.gz: 7f4821ac37a0cc4dea26cb920843e998c3dce0518c497c261b21a2ed7e5814b79bf460df2f834fe3baf94d47fbe51eca6a01d10c315c55ff612dded668788d3b
6
+ metadata.gz: d3b58626ea0c86f6384d4cd7207733333077bf3bde3fc46c1729718658745c34ac0cf4497e5396f681e33df754195c7141048ff1248db26309e7da9b37e31563
7
+ data.tar.gz: 84cac6c6ffe0dd30976f762d3d14c05fc3862eea70c51da8edce32e744bedfd989667fb676aa8f5905419616be61c215d3bc668b9be30e238ac73209922fc7b4
@@ -38,7 +38,7 @@ module Sibu
38
38
 
39
39
  def create
40
40
  @page = Sibu::Page.new(page_params)
41
- if @page.save
41
+ if @page.save_and_init
42
42
  redirect_to site_pages_url(@page.site_id), notice: "La page a bien été créée."
43
43
  else
44
44
  flash.now[:alert] = "Une erreur s'est produite lors de la création de la page."
@@ -7,5 +7,13 @@ module Sibu
7
7
  store :metadata, accessors: [:title, :description], coder: JSON
8
8
 
9
9
  validates_presence_of :name, :site, :language, :template
10
+
11
+ def save_and_init
12
+ if valid?
13
+ template_defaults = site.site_template.pages.select {|p| p[:template] == template}.first
14
+ self.sections = template_defaults[:sections] if template_defaults
15
+ end
16
+ save
17
+ end
10
18
  end
11
19
  end
@@ -31,7 +31,7 @@ module Sibu
31
31
  self.pages << Sibu::Page.new(p)
32
32
  end
33
33
  end
34
- save!
34
+ save
35
35
  end
36
36
 
37
37
  def pages_path_by_id
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain