trusty-cms 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1e344dee29ecc560615b8fa2f8bbf2022f213f7
4
- data.tar.gz: 3fc32b15c44fd8f643c85eb086dd9b0e78d5b3b5
3
+ metadata.gz: f20f67036374cef3064eb22bacb17d08739cf2a7
4
+ data.tar.gz: d4658bcafeb27b4068d654c90de3ef57afb84816
5
5
  SHA512:
6
- metadata.gz: b8bea05fe7e7ec1c2617fd9f80e07a6e81ff935509570ab1663bfc6bf81c74f9df56fbd43eba7028c7c0cb104a2a1cec65a7474f7a376f3e295c8a1e101c6f0f
7
- data.tar.gz: f3c8bfdffb0fd06c92e0136de84a1876e2f95054867fb735a5a4bd40c29a3ffe930dc440140c24651db01aa30f3256f2fe605e327cc20746ff07d0ecf4ad90c4
6
+ metadata.gz: 6e169ac5cd20306ecf77b3d7164fec690a7706c4367765035abf458f0734bc600e7eed09155041a5219e251a55752a66300f15937b6356db51506495a5c4cd1f
7
+ data.tar.gz: 8cc42d0af8bdd0c120e117cb55df2fdc7095758e51f8724795d2da6562c739ca955018ed2f7cd7a939e84f7782434c484685594d1394cd86e6a78a8b81e33976
data/Gemfile CHANGED
@@ -20,7 +20,6 @@ group :development, :test do
20
20
  gem 'poltergeist', '~> 1.14.0'
21
21
  gem 'factory_girl_rails', '~> 4.6.0'
22
22
  gem 'rails-observers', :git => 'https://github.com/rails/rails-observers'
23
- gem 'protected_attributes_continued'
24
23
  gem 'pry-rails'
25
24
  gem 'mysql2', '~> 0.4.2'
26
25
  gem 'pry-byebug'
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- trusty-cms (3.0.4)
11
+ trusty-cms (3.0.6)
12
12
  RedCloth (~> 4.3.2)
13
13
  acts_as_tree (~> 2.6.1)
14
14
  bundler (~> 1.7)
@@ -155,7 +155,7 @@ GEM
155
155
  json (2.1.0)
156
156
  launchy (2.4.3)
157
157
  addressable (~> 2.3)
158
- libv8 (3.16.14.19)
158
+ libv8 (3.16.14.19-x86_64-darwin-16)
159
159
  loofah (2.0.3)
160
160
  nokogiri (>= 1.5.9)
161
161
  mail (2.6.6)
@@ -176,8 +176,6 @@ GEM
176
176
  capybara (~> 2.1)
177
177
  cliver (~> 0.3.1)
178
178
  websocket-driver (>= 0.2.0)
179
- protected_attributes_continued (1.3.0)
180
- activemodel (~> 5.0)
181
179
  pry (0.10.4)
182
180
  coderay (~> 1.1.0)
183
181
  method_source (~> 0.8.1)
@@ -296,7 +294,6 @@ DEPENDENCIES
296
294
  mysql2 (~> 0.4.2)
297
295
  nokogiri (>= 1.7.1)
298
296
  poltergeist (~> 1.14.0)
299
- protected_attributes_continued
300
297
  pry (~> 0.10.0)
301
298
  pry-byebug
302
299
  pry-rails
@@ -1,9 +1,16 @@
1
1
  class Admin::PageFieldsController < Admin::ResourceController
2
2
  def create
3
- self.model = PageField.new(params[model_symbol])
3
+ self.model = PageField.new(page_fields_params)
4
4
  @controller_name = 'page'
5
5
  @template_name = 'edit'
6
6
  render :partial => "page_field", :object => model,
7
7
  :locals => { :page_field_counter => params[:page_field_counter].to_i}
8
8
  end
9
+
10
+ private
11
+
12
+ def page_fields_params
13
+ params.permit(:name, :content)
14
+ end
15
+
9
16
  end
@@ -1,9 +1,16 @@
1
1
  class Admin::PagePartsController < Admin::ResourceController
2
2
  def create
3
- self.model.attributes = params[model_symbol]
3
+ self.model.attributes = page_parts_params
4
4
  @controller_name = 'page'
5
5
  @template_name = 'edit'
6
6
  render :partial => "page_part", :object => model,
7
7
  :locals => {:page_part_counter => params[:index].to_i}
8
8
  end
9
+
10
+ private
11
+
12
+ def page_parts_params
13
+ params.permit(:name, :filter_id, :content)
14
+ end
15
+
9
16
  end
@@ -11,7 +11,7 @@ class Admin::PreferencesController < ApplicationController
11
11
  end
12
12
 
13
13
  def update
14
- if @user.update_attributes(params[:user])
14
+ if @user.update_attributes(preferences_params)
15
15
  redirect_to admin_configuration_path
16
16
  else
17
17
  flash[:error] = t('preferences_controller.error_updating')
@@ -26,4 +26,8 @@ class Admin::PreferencesController < ApplicationController
26
26
  @controller_name = 'user'
27
27
  @template_name = 'preferences'
28
28
  end
29
+
30
+ def preferences_params
31
+ params.require(:user).permit(:name, :email, :login, :password, :password_confirmation, :locale)
32
+ end
29
33
  end
@@ -58,7 +58,7 @@ class Admin::ResourceController < ApplicationController
58
58
  [:create, :update].each do |action|
59
59
  class_eval %{
60
60
  def #{action} # def create
61
- model.update_attributes!(params[model_symbol]) # model.update_attributes!(params[model_symbol])
61
+ model.update_attributes!(permitted_params[model_symbol]) # model.update_attributes!(params[model_symbol])
62
62
  response_for :#{action} # response_for :create
63
63
  end # end
64
64
  }, __FILE__, __LINE__
@@ -240,5 +240,14 @@ class Admin::ResourceController < ApplicationController
240
240
  params[:format] ||= 'html' unless request.xhr?
241
241
  end
242
242
 
243
+ def permitted_params
244
+ model_symbols = ActiveRecord::Base.descendants.map{|a| a.name.underscore.to_sym}
245
+ keys = params.keys.map{|k| k.underscore.to_sym}
246
+ valid_symbols = model_symbols & keys
247
+ valid_symbols.each do |symbol|
248
+ params[symbol].permit!
249
+ end
250
+ params
251
+ end
243
252
 
244
253
  end
data/app/models/layout.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  class Layout < ActiveRecord::Base
2
- attr_protected :created_at, :updated_at
3
2
 
4
3
  # Default Order
5
4
  default_scope {order("name")}
data/app/models/page.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  class Page < ActiveRecord::Base
2
- attr_protected :created_at, :updated_at
3
2
 
4
3
  class MissingRootPageError < StandardError
5
4
  def initialize(message = 'Database missing root page'); super end
@@ -9,7 +8,7 @@ class Page < ActiveRecord::Base
9
8
  before_save :update_virtual, :update_status, :set_allowed_children_cache
10
9
 
11
10
  # Associations
12
- acts_as_tree :order => 'virtual DESC, title ASC'
11
+ acts_as_tree :order => 'title ASC'
13
12
  has_many :parts, {:class_name => 'PagePart', :dependent => :destroy}, -> {order(:id)}
14
13
  accepts_nested_attributes_for :parts, :allow_destroy => true
15
14
  has_many :fields, {:class_name => 'PageField', :dependent => :destroy}, -> {order(:id)}
@@ -51,7 +50,9 @@ class Page < ActiveRecord::Base
51
50
  layout_without_inheritance
52
51
  end
53
52
  end
54
- alias_method_chain :layout, :inheritance
53
+
54
+ alias_method :layout_without_inheritance, :layout
55
+ alias_method :layout, :layout_with_inheritance
55
56
 
56
57
  def description
57
58
  self["description"]
@@ -1,4 +1,3 @@
1
1
  class PageField < ActiveRecord::Base
2
- attr_accessible :name, :content
3
2
  validates_presence_of :name
4
3
  end
@@ -1,5 +1,4 @@
1
1
  class PagePart < ActiveRecord::Base
2
- attr_accessible :name, :filter_id, :content
3
2
 
4
3
  # Default Order
5
4
  default_scope {order("name")}
@@ -71,7 +71,6 @@ module TrustyCms
71
71
  self.table_name = "config"
72
72
  after_save :update_cache
73
73
  attr_reader :definition
74
- attr_accessible :key
75
74
 
76
75
  class ConfigError < RuntimeError; end
77
76
 
data/app/models/user.rb CHANGED
@@ -2,7 +2,6 @@ require 'digest/sha1'
2
2
 
3
3
  class User < ActiveRecord::Base
4
4
  has_many :pages, :foreign_key => :created_by_id
5
- attr_protected 'why_is_this_needed'
6
5
 
7
6
  # Default Order
8
7
  default_scope {order("name")}