mongoid-forums 0.0.3 → 0.0.4

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mongoid_forums/admin/groups.js +2 -0
  3. data/app/assets/javascripts/mongoid_forums/application.js +2 -0
  4. data/app/assets/stylesheets/mongoid_forums/admin/groups.css +4 -0
  5. data/app/controllers/mongoid_forums/admin/base_controller.rb +8 -1
  6. data/app/controllers/mongoid_forums/admin/categories_controller.rb +52 -1
  7. data/app/controllers/mongoid_forums/admin/forums_controller.rb +54 -4
  8. data/app/controllers/mongoid_forums/admin/groups_controller.rb +87 -0
  9. data/app/controllers/mongoid_forums/application_controller.rb +32 -21
  10. data/app/controllers/mongoid_forums/forums_controller.rb +8 -1
  11. data/app/controllers/mongoid_forums/posts_controller.rb +13 -1
  12. data/app/controllers/mongoid_forums/topics_controller.rb +1 -2
  13. data/app/helpers/mongoid_forums/admin/groups_helper.rb +4 -0
  14. data/app/models/mongoid_forums/ability.rb +65 -0
  15. data/app/models/mongoid_forums/category.rb +18 -1
  16. data/app/models/mongoid_forums/forum.rb +23 -1
  17. data/app/models/mongoid_forums/group.rb +15 -0
  18. data/app/models/mongoid_forums/post.rb +3 -0
  19. data/app/models/mongoid_forums/subscription.rb +0 -1
  20. data/app/models/mongoid_forums/topic.rb +5 -1
  21. data/app/views/mongoid_forums/admin/base/index.haml +3 -2
  22. data/app/views/mongoid_forums/admin/categories/edit.haml +3 -0
  23. data/app/views/mongoid_forums/admin/categories/index.haml +21 -0
  24. data/app/views/mongoid_forums/admin/categories/show.haml +21 -0
  25. data/app/views/mongoid_forums/admin/forums/edit.haml +4 -0
  26. data/app/views/mongoid_forums/admin/forums/index.haml +25 -0
  27. data/app/views/mongoid_forums/admin/forums/show.haml +21 -0
  28. data/app/views/mongoid_forums/admin/groups/edit.haml +4 -0
  29. data/app/views/mongoid_forums/admin/groups/index.haml +23 -0
  30. data/app/views/mongoid_forums/admin/groups/new.haml +5 -0
  31. data/app/views/mongoid_forums/admin/groups/show.haml +19 -0
  32. data/app/views/mongoid_forums/forums/index.haml +2 -0
  33. data/app/views/mongoid_forums/forums/show.haml +27 -25
  34. data/app/views/mongoid_forums/posts/_post.haml +5 -4
  35. data/app/views/mongoid_forums/topics/show.haml +2 -3
  36. data/config/routes.rb +12 -3
  37. data/lib/mongoid_forums.rb +9 -1
  38. data/lib/mongoid_forums/default_permissions.rb +63 -0
  39. data/lib/mongoid_forums/version.rb +1 -1
  40. data/test/controllers/mongoid_forums/admin/groups_controller_test.rb +41 -0
  41. data/test/dummy/log/development.log +35218 -145038
  42. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/2dedb8177c20286c4259c1d58c5646cc +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/37b103f4623089af1456b90830fe941c +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/37f7e269b2ddbd05160232e59bf0288f +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/6b12ee5284cadf70954a584a88b6c529 +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/e2c4f946939f2d7d0b42d86383755cae +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  57. metadata +35 -10
  58. data/app/models/mongoid_forums/permission.rb +0 -96
  59. data/app/models/mongoid_forums/rank.rb +0 -9
  60. data/app/views/mongoid_forums/admin/categories/edit.html.erb +0 -2
  61. data/app/views/mongoid_forums/admin/forums/edit.html.erb +0 -2
  62. data/test/dummy/log/test.log +0 -51
  63. data/test/dummy/tmp/pids/server.pid +0 -1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-forums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - skipperguy12
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 2.0.6
97
+ - !ruby/object:Gem::Dependency
98
+ name: cancancan
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.10'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.10'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: haml
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +148,7 @@ files:
134
148
  - app/assets/javascripts/mongoid_forums/admin/base.js
135
149
  - app/assets/javascripts/mongoid_forums/admin/categories.js
136
150
  - app/assets/javascripts/mongoid_forums/admin/forums.js
151
+ - app/assets/javascripts/mongoid_forums/admin/groups.js
137
152
  - app/assets/javascripts/mongoid_forums/application.js
138
153
  - app/assets/javascripts/mongoid_forums/forums.js
139
154
  - app/assets/javascripts/mongoid_forums/posts.js
@@ -141,6 +156,7 @@ files:
141
156
  - app/assets/stylesheets/mongoid_forums/admin/base.css
142
157
  - app/assets/stylesheets/mongoid_forums/admin/categories.css
143
158
  - app/assets/stylesheets/mongoid_forums/admin/forums.css
159
+ - app/assets/stylesheets/mongoid_forums/admin/groups.css
144
160
  - app/assets/stylesheets/mongoid_forums/application.css
145
161
  - app/assets/stylesheets/mongoid_forums/forums.css
146
162
  - app/assets/stylesheets/mongoid_forums/posts.css
@@ -149,6 +165,7 @@ files:
149
165
  - app/controllers/mongoid_forums/admin/base_controller.rb
150
166
  - app/controllers/mongoid_forums/admin/categories_controller.rb
151
167
  - app/controllers/mongoid_forums/admin/forums_controller.rb
168
+ - app/controllers/mongoid_forums/admin/groups_controller.rb
152
169
  - app/controllers/mongoid_forums/application_controller.rb
153
170
  - app/controllers/mongoid_forums/forums_controller.rb
154
171
  - app/controllers/mongoid_forums/posts_controller.rb
@@ -157,28 +174,37 @@ files:
157
174
  - app/helpers/mongoid_forums/admin/base_helper.rb
158
175
  - app/helpers/mongoid_forums/admin/categories_helper.rb
159
176
  - app/helpers/mongoid_forums/admin/forums_helper.rb
177
+ - app/helpers/mongoid_forums/admin/groups_helper.rb
160
178
  - app/helpers/mongoid_forums/application_helper.rb
161
179
  - app/helpers/mongoid_forums/formatting_helper.rb
162
180
  - app/helpers/mongoid_forums/forums_helper.rb
163
181
  - app/helpers/mongoid_forums/posts_helper.rb
164
182
  - app/helpers/mongoid_forums/topics_helper.rb
183
+ - app/models/mongoid_forums/ability.rb
165
184
  - app/models/mongoid_forums/alert.rb
166
185
  - app/models/mongoid_forums/category.rb
167
186
  - app/models/mongoid_forums/concerns/subscribable.rb
168
187
  - app/models/mongoid_forums/concerns/viewable.rb
169
188
  - app/models/mongoid_forums/forum.rb
170
- - app/models/mongoid_forums/permission.rb
189
+ - app/models/mongoid_forums/group.rb
171
190
  - app/models/mongoid_forums/post.rb
172
- - app/models/mongoid_forums/rank.rb
173
191
  - app/models/mongoid_forums/subscription.rb
174
192
  - app/models/mongoid_forums/topic.rb
175
193
  - app/models/mongoid_forums/view.rb
176
194
  - app/views/layouts/mongoid_forums/application.haml
177
195
  - app/views/mongoid_forums/admin/base/index.haml
178
- - app/views/mongoid_forums/admin/categories/edit.html.erb
196
+ - app/views/mongoid_forums/admin/categories/edit.haml
197
+ - app/views/mongoid_forums/admin/categories/index.haml
179
198
  - app/views/mongoid_forums/admin/categories/new.haml
180
- - app/views/mongoid_forums/admin/forums/edit.html.erb
199
+ - app/views/mongoid_forums/admin/categories/show.haml
200
+ - app/views/mongoid_forums/admin/forums/edit.haml
201
+ - app/views/mongoid_forums/admin/forums/index.haml
181
202
  - app/views/mongoid_forums/admin/forums/new.haml
203
+ - app/views/mongoid_forums/admin/forums/show.haml
204
+ - app/views/mongoid_forums/admin/groups/edit.haml
205
+ - app/views/mongoid_forums/admin/groups/index.haml
206
+ - app/views/mongoid_forums/admin/groups/new.haml
207
+ - app/views/mongoid_forums/admin/groups/show.haml
182
208
  - app/views/mongoid_forums/forums/index.haml
183
209
  - app/views/mongoid_forums/forums/new.haml
184
210
  - app/views/mongoid_forums/forums/show.haml
@@ -197,6 +223,7 @@ files:
197
223
  - lib/generators/mongoid_forums/install_generator.rb
198
224
  - lib/generators/mongoid_forums/views_generator.rb
199
225
  - lib/mongoid_forums.rb
226
+ - lib/mongoid_forums/default_permissions.rb
200
227
  - lib/mongoid_forums/engine.rb
201
228
  - lib/mongoid_forums/sanitizer.rb
202
229
  - lib/mongoid_forums/version.rb
@@ -204,6 +231,7 @@ files:
204
231
  - test/controllers/mongoid_forums/admin/base_controller_test.rb
205
232
  - test/controllers/mongoid_forums/admin/categories_controller_test.rb
206
233
  - test/controllers/mongoid_forums/admin/forums_controller_test.rb
234
+ - test/controllers/mongoid_forums/admin/groups_controller_test.rb
207
235
  - test/controllers/mongoid_forums/forums_controller_test.rb
208
236
  - test/controllers/mongoid_forums/posts_controller_test.rb
209
237
  - test/controllers/mongoid_forums/topics_controller_test.rb
@@ -254,7 +282,6 @@ files:
254
282
  - test/dummy/config/secrets.yml
255
283
  - test/dummy/lib/templates/erb/scaffold/_form.html.erb
256
284
  - test/dummy/log/development.log
257
- - test/dummy/log/test.log
258
285
  - test/dummy/public/404.html
259
286
  - test/dummy/public/422.html
260
287
  - test/dummy/public/500.html
@@ -319,7 +346,6 @@ files:
319
346
  - test/dummy/tmp/cache/assets/development/sprockets/eaa7a7fe023d19cd34c33a47e6b303f3
320
347
  - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
321
348
  - test/dummy/tmp/cache/assets/development/sprockets/f91f775cd15edae9264ec0c23937c58b
322
- - test/dummy/tmp/pids/server.pid
323
349
  - test/fixtures/mongoid_forums/categories.yml
324
350
  - test/fixtures/mongoid_forums/forums.yml
325
351
  - test/fixtures/mongoid_forums/posts.yml
@@ -361,6 +387,7 @@ test_files:
361
387
  - test/controllers/mongoid_forums/admin/base_controller_test.rb
362
388
  - test/controllers/mongoid_forums/admin/categories_controller_test.rb
363
389
  - test/controllers/mongoid_forums/admin/forums_controller_test.rb
390
+ - test/controllers/mongoid_forums/admin/groups_controller_test.rb
364
391
  - test/controllers/mongoid_forums/forums_controller_test.rb
365
392
  - test/controllers/mongoid_forums/posts_controller_test.rb
366
393
  - test/controllers/mongoid_forums/topics_controller_test.rb
@@ -409,7 +436,6 @@ test_files:
409
436
  - test/dummy/config.ru
410
437
  - test/dummy/lib/templates/erb/scaffold/_form.html.erb
411
438
  - test/dummy/log/development.log
412
- - test/dummy/log/test.log
413
439
  - test/dummy/public/404.html
414
440
  - test/dummy/public/422.html
415
441
  - test/dummy/public/500.html
@@ -476,7 +502,6 @@ test_files:
476
502
  - test/dummy/tmp/cache/assets/development/sprockets/eaa7a7fe023d19cd34c33a47e6b303f3
477
503
  - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
478
504
  - test/dummy/tmp/cache/assets/development/sprockets/f91f775cd15edae9264ec0c23937c58b
479
- - test/dummy/tmp/pids/server.pid
480
505
  - test/fixtures/mongoid_forums/categories.yml
481
506
  - test/fixtures/mongoid_forums/forums.yml
482
507
  - test/fixtures/mongoid_forums/posts.yml
@@ -1,96 +0,0 @@
1
- module MongoidForums
2
- class Permission
3
-
4
- def initialize(user)
5
- allow "mongoid_forums/admin/forums", [:new]
6
- allow "mongoid_forums/forums", [:index, :show]
7
-
8
- allow "mongoid_forums/topics", [:show] do |topic|
9
- (topic.hidden && user.present? && topic.user_id == user.id) || !topic.hidden
10
- end
11
-
12
- if user.present?
13
- allow "mongoid_forums/posts", [:new, :create]
14
-
15
- allow "mongoid_forums/forums", [:new, :create]
16
- allow "mongoid_forums/redirect", [:forum, :topic, :posts, :subscriptions]
17
-
18
- allow "mongoid_forums/topics", [:my_subscriptions, :my_topics, :my_posts]
19
-
20
- allow "mongoid_forums/topics", [:edit, :update] do |topic|
21
- topic.user_id == user.id && !topic.locked && !topic.hidden
22
- end
23
-
24
- allow "mongoid_forums/posts", [:edit, :update] do |post|
25
- post.user_id == user.id && !post.topic.locked
26
- end
27
-
28
- allow "mongoid_forums/redirect", [:subscriptions]
29
- #allow_param :topic, [:name, posts: :text]
30
-
31
-
32
- rank = Rank.where(:members => user.id).first
33
-
34
- allow_all if rank && rank.admin
35
- end
36
- end
37
-
38
-
39
- def allow?(controller, action, resource = nil)
40
- puts controller
41
- puts action
42
- allowed = @allow_all || @allowed_actions[[controller.to_s, action.to_s]]
43
- allowed && (allowed == true || resource && allowed.call(resource))
44
- end
45
-
46
- def allow_all
47
- @allow_all = true
48
- end
49
-
50
- def allow(controllers, actions, &block)
51
- @allowed_actions ||= {}
52
- Array(controllers).each do |controller|
53
- Array(actions).each do |action|
54
- @allowed_actions[[controller.to_s, action.to_s]] = block || true
55
- end
56
- end
57
- end
58
-
59
- def allow_param(resource, attributes)
60
- @allowed_params ||= {}
61
- Array(resource).each do |resource|
62
- @allowed_params[resource.to_s] ||= []
63
- @allowed_params[resource.to_s] += Array(attributes).map(&:to_s)
64
- end
65
- end
66
-
67
- def allow_param?(resource, attribute)
68
- if @allow_all
69
- true
70
- elsif @allowed_params && @allowed_params[resource.to_s]
71
- @allowed_params[resource.to_s].include? attribute.to_s
72
- end
73
- end
74
-
75
- def allow_nested_param(resources, attribute, nested_attributes)
76
- @allowed_params ||= {}
77
- Array(resources).each do |resource|
78
- @allowed_params[resource.to_s] ||= []
79
- @allowed_params[resource.to_s] += [{ attribute.to_s => Array(nested_attributes).map(&:to_s)}]
80
- end
81
- end
82
-
83
- def permit_params!(params)
84
- if @allow_all
85
- params.permit!
86
- elsif @allowed_params
87
- @allowed_params.each do |resource, attributes|
88
- if params[resource].respond_to? :permit
89
- params[resource] = params[resource].permit(*attributes)
90
- end
91
- end
92
- end
93
- end
94
-
95
- end
96
- end
@@ -1,9 +0,0 @@
1
- module MongoidForums
2
- class Rank
3
- include Mongoid::Document
4
-
5
- field :members, type: Array, default: []
6
- field :admin, type: Boolean, default: false
7
-
8
- end
9
- end
@@ -1,2 +0,0 @@
1
- <h1>Admin::Categories#edit</h1>
2
- <p>Find me in app/views/mongoid_forums/admin/categories/edit.html.erb</p>
@@ -1,2 +0,0 @@
1
- <h1>Admin::Forums#edit</h1>
2
- <p>Find me in app/views/mongoid_forums/admin/forums/edit.html.erb</p>
@@ -1,51 +0,0 @@
1
- -----------------------------
2
- MongoidForumsTest: test_truth
3
- -----------------------------
4
- --------------------------------------------------------
5
- MongoidForums::TopicsControllerTest: test_should_get_new
6
- --------------------------------------------------------
7
- ---------------------------------------------------------
8
- MongoidForums::TopicsControllerTest: test_should_get_show
9
- ---------------------------------------------------------
10
- ---------------------------------------------------------
11
- MongoidForums::TopicsControllerTest: test_should_get_edit
12
- ---------------------------------------------------------
13
- ------------------------------------------------------------
14
- MongoidForums::TopicsControllerTest: test_should_get_destroy
15
- ------------------------------------------------------------
16
- -----------------------------------------------------------
17
- MongoidForums::TopicsControllerTest: test_should_get_create
18
- -----------------------------------------------------------
19
- -----------------------------------------------------------
20
- MongoidForums::TopicsControllerTest: test_should_get_update
21
- -----------------------------------------------------------
22
- --------------------------------------------
23
- WelcomeControllerTest: test_should_get_index
24
- --------------------------------------------
25
- Processing by WelcomeController#index as HTML
26
- Rendered welcome/index.html.erb (1.1ms)
27
- Completed 200 OK in 8ms (Views: 8.1ms)
28
- ----------------------------------------------------------
29
- MongoidForums::ForumsControllerTest: test_should_get_index
30
- ----------------------------------------------------------
31
- ---------------------------------------------------------
32
- MongoidForums::ForumsControllerTest: test_should_get_show
33
- ---------------------------------------------------------
34
- ----------------------------------------------------------
35
- MongoidForums::PostsControllerTest: test_should_get_create
36
- ----------------------------------------------------------
37
- ----------------------------------------------------------
38
- MongoidForums::PostsControllerTest: test_should_get_update
39
- ----------------------------------------------------------
40
- --------------------------------------------------------
41
- MongoidForums::PostsControllerTest: test_should_get_edit
42
- --------------------------------------------------------
43
- -----------------------------------------------------------
44
- MongoidForums::PostsControllerTest: test_should_get_destroy
45
- -----------------------------------------------------------
46
- --------------------------------------------------------
47
- MongoidForums::PostsControllerTest: test_should_get_show
48
- --------------------------------------------------------
49
- -------------------------------------------------------
50
- MongoidForums::PostsControllerTest: test_should_get_new
51
- -------------------------------------------------------
@@ -1 +0,0 @@
1
- 87649