the_role 1.6.9 → 1.7.0

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.
data/README.md CHANGED
@@ -203,13 +203,12 @@ You should to define **@ownership_checking_object** before invoke of **owner_req
203
203
 
204
204
  ```ruby
205
205
  class User
206
- after_create :set_default_role
206
+ before_create :set_default_role
207
207
 
208
208
  private
209
209
 
210
210
  def set_default_role
211
211
  self.role = Role.where(:name => :user).first
212
- self.save
213
212
  end
214
213
  end
215
214
  ```
@@ -379,6 +378,7 @@ new_role_hash = {
379
378
 
380
379
  ### Changelog
381
380
 
381
+ * 1.7.0 - mass assignment for User#role_id, doc, locales, changes in test app
382
382
  * 1.6.9 - assets precompile addon
383
383
  * 1.6.8 - doc, re dependencies
384
384
  * 1.6.7 - Es locale (beta 0.2)
@@ -394,8 +394,12 @@ new_role_hash = {
394
394
 
395
395
  **Es** by @igmarin
396
396
 
397
+ **zh_CN** by @doabit & @linjunpop
398
+
397
399
  ... waiting for contributors
398
400
 
401
+ ### MIT-LICENSE
402
+
399
403
  ##### Copyright (c) 2012 [Ilya N.Zykin]
400
404
 
401
405
  Permission is hereby granted, free of charge, to any person obtaining
@@ -0,0 +1,42 @@
1
+ zh_CN:
2
+ the_role:
3
+ role_created: 角色已创建
4
+ role_updated: 角色已更新
5
+ role_deleted: 角色已删除
6
+ section_created: 章节已创建
7
+ section_not_created: 章节没有被创建
8
+ section_rule_created: "章节的规则已创建"
9
+ section_rule_not_created: "章节的规则没有被创建"
10
+ section_rule_on: "章节的规则可有"
11
+ section_rule_off: "章节的规则不可有"
12
+ state_not_changed: "章节的规则没有改变"
13
+ section_deleted: 章节已删除
14
+ section_not_deleted: 章节没有被删除
15
+ section_rule_deleted: "章节的规则已被删除"
16
+ section_rule_not_deleted: "章节的规则没有被删除"
17
+
18
+ admin:
19
+ roles:
20
+ new:
21
+ create: 创建新角色
22
+ name: 角色名称 (字符串)
23
+ title: 角色标题 (文本)
24
+ description: 角色描述 (文本)
25
+ role:
26
+ role_name: '角色名称:'
27
+ title: '角色标题:'
28
+ role_description: '角色描述:'
29
+ delete_section: 删除章节
30
+ section_delete_confirm: '你想要删除章节?'
31
+ rule_delete_confirm: '你想删除规则?'
32
+ enable: 可用
33
+ disable: 不可用
34
+ delete_rule: 删除规则
35
+ new_section_placeholder: 新章节名称
36
+ create_section: 创建新章节
37
+ new_rule_placeholder: 新规则名称
38
+ create_rule: 创建新规则
39
+ sidebar:
40
+ roles_list: 角色列表
41
+ new_role: 创建新角色
42
+ delete_role_confirm: '你确定? 可能存在风险!'
data/lib/tasks/roles.rake CHANGED
@@ -1,5 +1,6 @@
1
1
  namespace :db do
2
2
  namespace :roles do
3
+
3
4
  # rake db:roles:test
4
5
  desc 'create roles'
5
6
  task :test => :environment do
@@ -9,16 +10,23 @@ namespace :db do
9
10
  :administrator => true
10
11
  }
11
12
  }
12
- Role.new(
13
- :name => :admin,
14
- :title => 'Administrator',
13
+
14
+ Role.create!(
15
+ :name => :admin,
16
+ :title => 'Administrator',
15
17
  :description => 'Role for administrator',
16
- :the_role => role.to_json
17
- ).save!
18
+ :the_role => role.to_json
19
+ )
20
+
18
21
  puts 'Administrator'
19
22
 
20
23
  # MODERATOR
21
24
  role = {
25
+ :users => {
26
+ :edit => true,
27
+ :show => true,
28
+ :update => true
29
+ },
22
30
  :moderator => {
23
31
  :pages => true
24
32
  },
@@ -26,95 +34,101 @@ namespace :db do
26
34
  :html => true
27
35
  }
28
36
  }
29
- Role.new(
37
+
38
+ Role.create!(
30
39
  :name => :moderator,
31
- :title => 'Moderator of pages',
40
+ :title => 'Moderator of pages',
32
41
  :description => "Moderator #1",
33
- :the_role => role.to_json
34
- ).save!
42
+ :the_role => role.to_json
43
+ )
44
+
35
45
  puts 'Moderator of pages'
36
46
 
37
47
  # USER
38
48
  role = {
39
49
  :users => {
40
- :cabinet => true,
41
- :update => true,
42
- :avatar_upload => true
50
+ :edit => true,
51
+ :show => true,
52
+ :update => true
43
53
  },
44
54
  :profiles => {
45
- :edit => true,
55
+ :edit => true,
46
56
  :update => true
47
57
  },
48
- :articles => {
49
- :new => true,
50
- :create => true,
51
- :edit => true,
52
- :update => true,
58
+ :articles => {
59
+ :new => true,
60
+ :create => true,
61
+ :edit => true,
62
+ :update => true,
53
63
  :destroy => true,
54
- :tags => false
64
+ :tags => false
55
65
  },
56
66
  :pages => {
57
- :new => true,
58
- :create => true,
59
- :edit => true,
60
- :update => true,
67
+ :new => true,
68
+ :create => true,
69
+ :edit => true,
70
+ :update => true,
61
71
  :destroy => true,
62
- :tags => true
72
+ :tags => true
63
73
  },
64
74
  :markup => {
65
75
  :html => false
66
76
  }
67
77
  }
68
- Role.new(
69
- :name => :user,
70
- :title => 'User',
78
+
79
+ Role.create!(
80
+ :name => :user,
81
+ :title => 'User',
71
82
  :description => "Role for User",
72
- :the_role => role.to_json
73
- ).save!
83
+ :the_role => role.to_json
84
+ )
85
+
74
86
  puts 'User'
75
87
 
76
88
  # DEMO
77
89
  role = {
78
90
  :users => {
79
- :cabinet => true,
80
- :update => false,
81
- :avatar_upload => false
91
+ :edit => true,
92
+ :show => true,
93
+ :update => true
82
94
  },
83
95
  :profiles => {
84
- :edit => true,
96
+ :edit => true,
85
97
  :update => false
86
98
  },
87
- :articles => {
88
- :new => true,
89
- :show => true,
90
- :create => false,
91
- :edit => true,
92
- :update => false,
99
+ :articles => {
100
+ :new => true,
101
+ :show => true,
102
+ :create => false,
103
+ :edit => true,
104
+ :update => false,
93
105
  :destroy => false,
94
- :tags => false
106
+ :tags => false
95
107
  },
96
108
  :pages => {
97
- :new => true,
98
- :show => true,
99
- :create => false,
100
- :edit => true,
101
- :update => false,
109
+ :new => true,
110
+ :show => true,
111
+ :create => false,
112
+ :edit => true,
113
+ :update => false,
102
114
  :destroy => false,
103
- :tags => false
115
+ :tags => false
104
116
  },
105
117
  :markup => {
106
118
  :html => false
107
119
  }
108
120
  }
109
- Role.new(
110
- :name => :demo,
111
- :title => 'Demo',
121
+
122
+ Role.create!(
123
+ :name => :demo,
124
+ :title => 'Demo',
112
125
  :description => "Demo user",
113
- :the_role => role.to_json
114
- ).save!
126
+ :the_role => role.to_json
127
+ )
128
+
115
129
  puts 'Demo'
116
130
 
117
131
  puts 'Roles created'
118
- end#test
119
- end#roles
120
- end#db
132
+ end
133
+ end
134
+ end
@@ -58,10 +58,6 @@ module TheRole
58
58
  the_role
59
59
  end
60
60
 
61
- def to_s
62
- the_role
63
- end
64
-
65
61
  # U
66
62
 
67
63
  # source_hash will be reset to false
@@ -23,8 +23,7 @@ module TheRole
23
23
 
24
24
  def self.included(base)
25
25
  base.class_eval do
26
- belongs_to :role
27
- attr_accessible :role
26
+ belongs_to :role
28
27
  after_save { |user| user.instance_variable_set(:@role_hash, nil) }
29
28
  end
30
29
  end
@@ -1,3 +1,3 @@
1
1
  module TheRole
2
- VERSION = "1.6.9"
2
+ VERSION = "1.7.0"
3
3
  end
data/the_role.gemspec CHANGED
@@ -5,7 +5,7 @@ require "the_role/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "the_role"
7
7
  s.version = TheRole::VERSION
8
- s.authors = ["Ilya N. Zykin [the-teacher], John Henderson [jhenderson]"]
8
+ s.authors = ["Ilya N. Zykin [the-teacher]"]
9
9
  s.email = ["zykin-ilya@ya.ru"]
10
10
  s.homepage = "https://github.com/the-teacher/the_role"
11
11
  s.summary = %q{Authorization lib for Rails 3 with Web Interface, aka CanCan killer}
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_role
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.9
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Ilya N. Zykin [the-teacher], John Henderson [jhenderson]
8
+ - Ilya N. Zykin [the-teacher]
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
16
- requirement: &16822500 !ruby/object:Gem::Requirement
16
+ requirement: &21325720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16822500
24
+ version_requirements: *21325720
25
25
  description: Authorization lib for Rails 3 with Web Interface, aka CanCan killer
26
26
  email:
27
27
  - zykin-ilya@ya.ru
@@ -33,7 +33,6 @@ files:
33
33
  - .rvmrc.example
34
34
  - Bye_bye_CanCan_I_got_the_Role.png
35
35
  - Gemfile
36
- - MIT-LICENSE
37
36
  - README.md
38
37
  - Rakefile
39
38
  - app/assets/javascripts/admin_the_role.js
@@ -56,6 +55,7 @@ files:
56
55
  - config/locales/en.yml
57
56
  - config/locales/es.yml
58
57
  - config/locales/ru.yml
58
+ - config/locales/zh_CN.yml
59
59
  - config/routes.rb
60
60
  - db/migrate/20111025025129_create_roles.rb
61
61
  - lib/tasks/roles.rake
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011 [name of plugin creator]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.