noodall-devise 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/app/controllers/admin/users_controller.rb +15 -6
- data/app/models/user.rb +8 -4
- data/app/views/admin/users/index.html.erb +3 -3
- data/app/views/admin/users/show.html.erb +14 -9
- data/features/manage_users.feature +2 -1
- data/features/step_definitions/user_steps.rb +4 -0
- data/lib/noodall/devise/engine.rb +3 -3
- data/lib/noodall/devise/version.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -2
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
noodall-devise (0.0
|
4
|
+
noodall-devise (0.1.0)
|
5
5
|
devise (~> 1.1.3)
|
6
6
|
mm-devise (~> 1.1.6)
|
7
7
|
|
8
8
|
PATH
|
9
9
|
remote: /Users/steve/Gems/noodall-ui
|
10
10
|
specs:
|
11
|
-
noodall-ui (0.0.
|
11
|
+
noodall-ui (0.0.5)
|
12
12
|
dynamic_form
|
13
13
|
noodall-core
|
14
14
|
thoughtbot-sortable_table (= 0.0.6)
|
@@ -124,7 +124,7 @@ GEM
|
|
124
124
|
jnunemaker-validatable (~> 1.8.4)
|
125
125
|
plucky (~> 0.3.5)
|
126
126
|
nokogiri (1.4.3.1)
|
127
|
-
noodall-core (0.1.
|
127
|
+
noodall-core (0.1.1)
|
128
128
|
canable (= 0.1.1)
|
129
129
|
mongo_mapper (= 0.8.4)
|
130
130
|
ramdiv-mongo_mapper_acts_as_tree (= 0.1.1)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Admin::UsersController < Noodall::Admin::BaseController
|
2
2
|
include SortableTable::App::Controllers::ApplicationController
|
3
|
+
include Canable::Enforcers
|
3
4
|
sortable_attributes :name, :email, :role
|
5
|
+
before_filter :enforce_admin_permission, :except => :index
|
4
6
|
|
5
7
|
# GET /users
|
6
8
|
# GET /users.xml
|
@@ -28,12 +30,7 @@ class Admin::UsersController < Noodall::Admin::BaseController
|
|
28
30
|
# POST /users
|
29
31
|
# POST /users.xml
|
30
32
|
def create
|
31
|
-
@user = User.new(params[: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
|
33
|
+
@user = User.new(params[:user])
|
37
34
|
respond_to do |format|
|
38
35
|
if @user.save
|
39
36
|
flash[:notice] = 'User was successfully created.'
|
@@ -73,6 +70,7 @@ class Admin::UsersController < Noodall::Admin::BaseController
|
|
73
70
|
# DELETE /users/1.xml
|
74
71
|
def destroy
|
75
72
|
@user = User.find(params[:id])
|
73
|
+
|
76
74
|
@user.destroy
|
77
75
|
flash[:notice] = 'User was successfully deleted.'
|
78
76
|
|
@@ -82,4 +80,15 @@ class Admin::UsersController < Noodall::Admin::BaseController
|
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
83
|
+
# Uses tag cloud to render all groups
|
84
|
+
def groups
|
85
|
+
render :json => User.tag_cloud
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def enforce_admin_permission
|
91
|
+
raise Canable::Transgression unless current_user.admin?
|
92
|
+
end
|
93
|
+
|
85
94
|
end
|
data/app/models/user.rb
CHANGED
@@ -2,20 +2,24 @@ class User
|
|
2
2
|
include MongoMapper::Document
|
3
3
|
# Include default devise modules. Others available are:
|
4
4
|
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
5
|
-
devise :database_authenticatable,
|
5
|
+
devise :database_authenticatable,
|
6
6
|
:recoverable, :rememberable, :trackable, :validatable
|
7
7
|
|
8
8
|
include Canable::Cans
|
9
|
-
|
10
|
-
key :groups, Array
|
9
|
+
plugin Noodall::Tagging
|
11
10
|
|
11
|
+
key :name, String
|
12
12
|
timestamps!
|
13
13
|
|
14
|
+
alias_attribute :groups, :tags
|
15
|
+
alias_attribute :group_list, :tag_list
|
16
|
+
|
14
17
|
def full_name
|
15
18
|
name || email
|
16
19
|
end
|
17
20
|
|
18
21
|
def admin?
|
19
|
-
|
22
|
+
tags.include?('admin')
|
20
23
|
end
|
24
|
+
|
21
25
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<h1>Listing Users</h1>
|
2
2
|
|
3
3
|
<ul class="choices">
|
4
|
-
<li><%= link_to 'Create New User', new_admin_user_path %></li>
|
4
|
+
<li><%= link_to 'Create New User', new_admin_user_path, :class => 'button' %></li>
|
5
5
|
</ul>
|
6
6
|
|
7
7
|
<a class="tooltip" href="/cms_help.pdf"> </a>
|
@@ -20,8 +20,8 @@
|
|
20
20
|
<% for user in @users -%>
|
21
21
|
<tr>
|
22
22
|
<td><%= link_to user.name, [:admin, user], :class => 'edit', :title => 'Edit this user' %></td>
|
23
|
-
<td><%= user.email %></td>
|
24
|
-
<td><%= user.
|
23
|
+
<td><%= mail_to user.email %></td>
|
24
|
+
<td><%= user.group_list %></td>
|
25
25
|
<td><%= link_to 'Delete', [:admin, user], :confirm => 'Are you sure?', :method => :delete, :class => 'delete', :title => 'Delete this user' %></td>
|
26
26
|
</tr>
|
27
27
|
<% end %>
|
@@ -4,33 +4,38 @@
|
|
4
4
|
<%= f.error_messages %>
|
5
5
|
|
6
6
|
<p>
|
7
|
+
<span class="tooltip" title="Enter the name of this user"> </span>
|
7
8
|
<%= f.label :name %><br/>
|
8
|
-
|
9
|
+
<span class="input-wrap"><%= f.text_field :name %></span>
|
9
10
|
</p>
|
10
11
|
|
11
12
|
<p>
|
13
|
+
<span class="tooltip" title="Enter the email address the user will use to login"> </span>
|
12
14
|
<%= f.label :email %><br/>
|
13
|
-
|
15
|
+
<span class="input-wrap"><%= f.text_field :email %></span>
|
14
16
|
</p>
|
15
17
|
|
16
18
|
<p>
|
19
|
+
<span class="tooltip" title="Enter the a password for the user"> </span>
|
17
20
|
<%= f.label :password %><br/>
|
18
|
-
|
19
|
-
<div id="password-meter"><strong>Strength</strong><div id = "psContainer"><div id = "psStrength"></div></div></div>
|
21
|
+
<span class="input-wrap"><%= f.password_field :password, :onKeyUp => "updateStrength(this.value)" %></span>
|
20
22
|
</p>
|
21
23
|
|
22
24
|
<p>
|
25
|
+
<span class="tooltip" title="Enter the password again to confirm it is correct"> </span>
|
23
26
|
<%= f.label :password_confirmation %><br/>
|
24
|
-
|
27
|
+
<span class="input-wrap"><%= f.password_field :password_confirmation %></span>
|
25
28
|
</p>
|
26
29
|
|
27
30
|
<p>
|
28
|
-
|
29
|
-
<%= f.
|
31
|
+
<span class="tooltip" title="Enter the groups this user belongs to (comma seperated)"> </span>
|
32
|
+
<%= f.label :group_list, "Groups" %><br/>
|
33
|
+
<span class="input-wrap"><%= f.text_field :group_list %></span>
|
30
34
|
</p>
|
31
35
|
|
32
|
-
<p>
|
33
|
-
<%= f.submit @user.new_record? ? 'Create' : 'Update', :disable_with => 'Submitting...'
|
36
|
+
<p class="fixed-form">
|
37
|
+
<%= f.submit @user.new_record? ? 'Create' : 'Update', :disable_with => 'Submitting...', :class => 'update' %>
|
38
|
+
<%= link_to 'Cancel', admin_users_path, :class => 'cancel' %>
|
34
39
|
</p>
|
35
40
|
<% end %>
|
36
41
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Noodall
|
2
2
|
module Devise
|
3
3
|
class Engine < Rails::Engine
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
initializer "static assets" do |app|
|
5
|
+
Noodall::UI.menu_items['Users'] = :admin_users_path
|
6
|
+
end
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noodall-devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors: []
|
13
13
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-05 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|