beef-admin_area 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/admin/users_controller.rb +12 -10
- data/beef-admin_area.gemspec +5 -5
- data/config/routes.rb +1 -0
- data/generators/admin_area_files/admin_area_files_generator.rb +0 -1
- data/lib/admin_area.rb +8 -7
- metadata +35 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Admin::UsersController < Admin::BaseController
|
2
2
|
authorise :roles => :admin
|
3
|
-
sortable_attributes :name, :email, :role
|
3
|
+
sortable_attributes :name, :email, :role
|
4
4
|
|
5
5
|
# GET /users
|
6
6
|
# GET /users.xml
|
@@ -27,13 +27,15 @@ class Admin::UsersController < Admin::BaseController
|
|
27
27
|
|
28
28
|
# POST /users
|
29
29
|
# POST /users.xml
|
30
|
-
def create
|
31
|
-
@user = User.new(params[:user])
|
32
|
-
|
33
|
-
|
30
|
+
def create
|
31
|
+
@user = User.new(params[:user]) do |user|
|
32
|
+
# No need for email confirmation
|
33
|
+
user.email_confirmed = true
|
34
|
+
# Because mass assignment is protected
|
35
|
+
user.role = params[:user][:role]
|
36
|
+
end
|
34
37
|
respond_to do |format|
|
35
38
|
if @user.save
|
36
|
-
@user.confirm_email!
|
37
39
|
flash[:notice] = 'User was successfully created.'
|
38
40
|
format.html { redirect_to(admin_users_url) }
|
39
41
|
format.xml { render :xml => @user, :status => :created, :location => @user }
|
@@ -46,7 +48,7 @@ class Admin::UsersController < Admin::BaseController
|
|
46
48
|
|
47
49
|
# PUT /users/1
|
48
50
|
# PUT /users/1.xml
|
49
|
-
def update
|
51
|
+
def update
|
50
52
|
@user = User.find(params[:id])
|
51
53
|
# Because mass assignment is protected
|
52
54
|
@user.role = params[:user][:role]
|
@@ -68,11 +70,11 @@ class Admin::UsersController < Admin::BaseController
|
|
68
70
|
@user = User.find(params[:id])
|
69
71
|
@user.destroy
|
70
72
|
flash[:notice] = 'User was successfully deleted.'
|
71
|
-
|
73
|
+
|
72
74
|
respond_to do |format|
|
73
75
|
format.html { redirect_to(admin_users_url) }
|
74
76
|
format.xml { head :ok }
|
75
77
|
end
|
76
78
|
end
|
77
|
-
|
78
|
-
end
|
79
|
+
|
80
|
+
end
|
data/beef-admin_area.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{beef-admin_area}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve England"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-03}
|
13
13
|
s.email = %q{steve@wearebeef.co.uk}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -198,11 +198,11 @@ Gem::Specification.new do |s|
|
|
198
198
|
s.homepage = %q{http://github.com/beef/admin}
|
199
199
|
s.rdoc_options = ["--charset=UTF-8"]
|
200
200
|
s.require_paths = ["lib"]
|
201
|
-
s.rubygems_version = %q{1.3.
|
201
|
+
s.rubygems_version = %q{1.3.6}
|
202
202
|
s.summary = %q{Rails engine that provides a standard admin area with user managament}
|
203
203
|
s.test_files = [
|
204
|
-
"test/
|
205
|
-
"test/
|
204
|
+
"test/admin_area_test.rb",
|
205
|
+
"test/test_helper.rb"
|
206
206
|
]
|
207
207
|
|
208
208
|
if s.respond_to? :specification_version then
|
data/config/routes.rb
CHANGED
data/lib/admin_area.rb
CHANGED
@@ -9,11 +9,11 @@ module Beef
|
|
9
9
|
controller.class_eval do
|
10
10
|
helper_method :authorised?
|
11
11
|
helper_method :not_authorised?
|
12
|
-
|
12
|
+
|
13
13
|
hide_action :authorised?, :authorise, :not_authorised?
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
module ClassMethods
|
18
18
|
def authorise(options)
|
19
19
|
raise ArgumentError, 'Roles must be suplied' if options[:roles].nil?
|
@@ -27,34 +27,35 @@ module Beef
|
|
27
27
|
def authorise(*roles)
|
28
28
|
deny_access("You do not have the required access privileges to access page") unless current_user.authorised?(*roles)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def authorised?(*roles, &block)
|
32
32
|
return unless current_user.authorised?(*roles)
|
33
33
|
if block_given?
|
34
34
|
yield
|
35
35
|
else
|
36
36
|
return true
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def not_authorised?(*roles, &block)
|
41
41
|
return if current_user.authorised?(*roles)
|
42
42
|
if block_given?
|
43
43
|
yield
|
44
44
|
else
|
45
45
|
return true
|
46
|
-
end
|
46
|
+
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
module Roles
|
53
53
|
|
54
54
|
def self.included(base)
|
55
55
|
base.send(:include, InstanceMethods)
|
56
56
|
|
57
57
|
base.class_eval do
|
58
|
+
attr_protected :role
|
58
59
|
User::ROLES.each do |r|
|
59
60
|
self.class_eval <<-RUBY
|
60
61
|
def #{r}?
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beef-admin_area
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Steve England
|
@@ -9,39 +14,49 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-03 00:00:00 +00:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: clearance
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 6
|
30
|
+
- 6
|
23
31
|
version: 0.6.6
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: thoughtbot-sortable_table
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
33
43
|
version: "0"
|
34
|
-
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
35
46
|
- !ruby/object:Gem::Dependency
|
36
47
|
name: will_paginate
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
50
|
requirements:
|
41
51
|
- - ">="
|
42
52
|
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 2
|
55
|
+
- 3
|
56
|
+
- 8
|
43
57
|
version: 2.3.8
|
44
|
-
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
45
60
|
description:
|
46
61
|
email: steve@wearebeef.co.uk
|
47
62
|
executables: []
|
@@ -243,21 +258,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
258
|
requirements:
|
244
259
|
- - ">="
|
245
260
|
- !ruby/object:Gem::Version
|
261
|
+
segments:
|
262
|
+
- 0
|
246
263
|
version: "0"
|
247
|
-
version:
|
248
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
265
|
requirements:
|
250
266
|
- - ">="
|
251
267
|
- !ruby/object:Gem::Version
|
268
|
+
segments:
|
269
|
+
- 0
|
252
270
|
version: "0"
|
253
|
-
version:
|
254
271
|
requirements: []
|
255
272
|
|
256
273
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.3.
|
274
|
+
rubygems_version: 1.3.6
|
258
275
|
signing_key:
|
259
276
|
specification_version: 3
|
260
277
|
summary: Rails engine that provides a standard admin area with user managament
|
261
278
|
test_files:
|
262
|
-
- test/test_helper.rb
|
263
279
|
- test/admin_area_test.rb
|
280
|
+
- test/test_helper.rb
|