constructor-pages 0.8.0 → 0.8.1

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: d0457fa097a8f3640bda13ce1f9699d1de07fe13
4
- data.tar.gz: 2dbd8ce3ee79fd7a4faa636823dc87ee6710b532
3
+ metadata.gz: c078ab91ea33dd0cdfc25092efd3969d3978861f
4
+ data.tar.gz: b943b4a056a152bdac0d0d858ade1fca1b61c79f
5
5
  SHA512:
6
- metadata.gz: 41e7f40d889a96c0210994feb7362c743912c700c373e49091a7d4b7ac51bb40a2896fa2899016d30bea7659420cbf88d54399aee5346051418c2c071f087732
7
- data.tar.gz: 1384f5b705a64fda65ae8d1ef04c62c29071d487bdd038ee9322179b2c046b5aa3f68100e51ae4b9810c9b291dd7d073ae11a7c43699078702939fc1d75aee8a
6
+ metadata.gz: f674c9622f7be5947ddc8a6b63e00a3251edccfa56ac4096039d09b60e883f95feac19e52f9e70207588024ab6aa50172f3b0e31ab8988eb4f2bf17438cab930
7
+ data.tar.gz: 39fdf84915c22c79bb1e11e92541f78fbb7a5a220483558df018935e908163d29a72c092c6200ecaaab070c20de23f0b26f73b736dfbf3e9c5f26e9fd9cbe0d6
@@ -10,7 +10,7 @@ module ConstructorPages
10
10
 
11
11
  def index
12
12
  @pages = Page.includes(:template).load
13
- @pages_cache = Digest::MD5.hexdigest(@pages.map{|p| [p.name, p.lft, p.template_id]}.join)
13
+ @pages_cache = Digest::MD5.hexdigest(@pages.map{|p| [p.name, p.url, p.lft, p.template_id]}.join)
14
14
  @template_exists = Template.count != 0
15
15
  flash[:notice] = 'Create at least one template' unless @template_exists
16
16
  end
@@ -56,6 +56,7 @@ module ConstructorPages
56
56
  @page = Page.new page_params
57
57
 
58
58
  if @page.save
59
+ @page.touch_branch
59
60
  redirect_to pages_path, notice: t(:page_success_added, name: @page.name)
60
61
  else
61
62
  render :new
@@ -72,6 +73,7 @@ module ConstructorPages
72
73
  if @page.update page_params
73
74
  @page.create_fields_values if _template_changed
74
75
  @page.update_fields_values params[:fields]
76
+ @page.touch_branch
75
77
 
76
78
  redirect_to pages_path, notice: t(:page_success_updated, name: @page.name)
77
79
  else
@@ -80,7 +82,9 @@ module ConstructorPages
80
82
  end
81
83
 
82
84
  def destroy
83
- @page = Page.find(params[:id]).destroy
85
+ @page = Page.find(params[:id])
86
+ @page.touch_branch
87
+ @page.destroy
84
88
  redirect_to pages_path, notice: t(:page_success_removed, name: @page.name)
85
89
  end
86
90
 
@@ -133,6 +133,11 @@ module ConstructorPages
133
133
  # Check if link specified
134
134
  def redirect?; url != link && !link.empty? end
135
135
 
136
+ # Touch all pages in same branch
137
+ def touch_branch
138
+ [ancestors, descendants].each {|p| p.map(&:touch)}
139
+ end
140
+
136
141
  # When method missing it get/set field value or get page in branch
137
142
  #
138
143
  # Examples:
@@ -165,7 +170,7 @@ module ConstructorPages
165
170
 
166
171
  # Reload all descendants
167
172
  def descendants_update
168
- descendants.map(&:save) if self.url_changed?
173
+ descendants.map(&:save) if self.full_url_changed?
169
174
  end
170
175
  end
171
176
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # Boolean type. Render as checkbox.
6
6
  class BooleanType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # Date time. Render as three select lists (day, month, year).
6
6
  class DateType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # Float type. Render small text field.
6
6
  class FloatType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # HTML type. Render ckeditor wysiwyg.
6
6
  class HtmlType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,15 +5,15 @@ module ConstructorPages
5
5
  # Image type. Render select file field.
6
6
  class ImageType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
 
10
10
  image_accessor :value
11
11
 
12
- validates :value, :presence => true
12
+ validates :value, presence: true
13
13
  # Max size is 5 MB
14
- validates_size_of :value, :maximum => 5.megabytes, :message => :incorrect_size
14
+ validates_size_of :value, maximum: 5.megabytes, message: :incorrect_size
15
15
  # Accept only jpeg, png, gif
16
- validates_property :mime_type, :of => :value, :in => %w(image/jpeg image/png image/gif), :message => :incorrect_format
16
+ validates_property :mime_type, of: :value, in: %w(image/jpeg image/png image/gif), message: :incorrect_format
17
17
  end
18
18
  end
19
19
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # Integer type. Render small text field.
6
6
  class IntegerType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # String type. Render large text field.
6
6
  class StringType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module ConstructorPages
5
5
  # Text type. Render textarea.
6
6
  class TextType < ActiveRecord::Base
7
7
  belongs_to :field
8
- belongs_to :page
8
+ belongs_to :page, touch: true
9
9
  end
10
10
  end
11
11
  end
@@ -1 +1 @@
1
- = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2'
1
+ = number_field_tag "fields[#{field.code_name}]", page.get_field_value(field.code_name), class: 'span2', step: 'any'
@@ -291,6 +291,19 @@ module ConstructorPages
291
291
  page.redirect?.should be_true
292
292
  end
293
293
  end
294
+
295
+ describe '#touch_branch' do
296
+ it 'should touch all pages in same branch' do
297
+ page = Page.create name: 'Hello world'
298
+ second_page = Page.create name: 'Again', parent: page
299
+ page.reload
300
+
301
+ updated = second_page.updated_at
302
+ page.touch_branch
303
+ second_page.reload
304
+ second_page.updated_at.should_not == updated
305
+ end
306
+ end
294
307
  end
295
308
 
296
309
  context 'ATTRIBUTES' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructor-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: constructor-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dragonfly
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +168,6 @@ files:
168
168
  - app/views/constructor_pages/fields/types/_integer.haml
169
169
  - app/views/constructor_pages/fields/types/_string.haml
170
170
  - app/views/constructor_pages/fields/types/_text.haml
171
- - app/views/constructor_pages/pages/_breadcrumbs.haml
172
171
  - app/views/constructor_pages/pages/_field.haml
173
172
  - app/views/constructor_pages/pages/_form.haml
174
173
  - app/views/constructor_pages/pages/edit.haml
@@ -1,7 +0,0 @@
1
- - unless page.ancestors.empty?
2
- %ul.breadcrumb
3
- - page.ancestors.each do |i|
4
- - if i.in_nav
5
- %li
6
- = link_to i.name, i.full_url, title: i.name, class: 'b-page-json'
7
- %span{class: 'divider'} /