muck-users 0.3.7 → 0.3.8
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/muck/users_controller.rb +59 -41
- data/app/views/admin/users/_row.html.erb +1 -0
- data/app/views/admin/users/_table.html.erb +1 -0
- data/app/views/admin/users/edit.html.erb +30 -0
- data/app/views/admin/users/permissions.html.erb +1 -0
- data/app/views/admin/users/row.js.erb +3 -0
- data/config/muck_users_routes.rb +1 -1
- data/locales/en.yml +4 -2
- data/muck-users.gemspec +3 -3
- data/test/rails_root/test/functional/admin/users_controller_test.rb +71 -1
- metadata +3 -3
- data/app/views/admin/users/update_activate.js.erb +0 -2
- data/app/views/admin/users/update_permissions.js.erb +0 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.8
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Admin::Muck::UsersController < Admin::Muck::BaseController
|
2
2
|
unloadable
|
3
3
|
|
4
|
-
before_filter :get_user, :only => [:update, :destroy, :permissions]
|
4
|
+
before_filter :get_user, :only => [:edit, :update, :destroy, :permissions]
|
5
5
|
before_filter :setup_subnavigation
|
6
6
|
|
7
7
|
def index
|
@@ -62,70 +62,82 @@ class Admin::Muck::UsersController < Admin::Muck::BaseController
|
|
62
62
|
def ajax_search
|
63
63
|
search_results
|
64
64
|
respond_to do |format|
|
65
|
-
format.html
|
66
|
-
render :partial => 'admin/users/table', :layout => false
|
67
|
-
end
|
65
|
+
format.html { render :partial => 'admin/users/table', :layout => false }
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
69
|
+
def edit
|
70
|
+
render :template => 'admin/users/edit'
|
71
|
+
end
|
72
|
+
|
71
73
|
def update
|
72
74
|
|
73
75
|
if params[:deactivate]
|
74
76
|
if is_me?(@user)
|
75
|
-
|
77
|
+
flash[:notice] = translate("muck.users.cannot_deactivate_yourself")
|
76
78
|
else
|
77
|
-
if @user.
|
78
|
-
|
79
|
+
if @user.admin?
|
80
|
+
flash[:notice] = translate('muck.users.cant_disable_admin')
|
79
81
|
else
|
80
|
-
|
82
|
+
if @user.deactivate!
|
83
|
+
return update_activate(translate('muck.users.user_marked_inactive'))
|
84
|
+
else
|
85
|
+
flash[:notice] = translate('muck.users.user_not_deactivated_error')
|
86
|
+
end
|
81
87
|
end
|
82
88
|
end
|
83
89
|
elsif params[:activate]
|
84
90
|
if @user.activate!
|
85
91
|
return update_activate(translate('muck.users.user_marked_active'))
|
86
92
|
else
|
87
|
-
|
93
|
+
flash[:notice] = translate('muck.users.user_not_activated_error')
|
88
94
|
end
|
89
|
-
|
95
|
+
elsif params[:update_roles]
|
96
|
+
params[:user] ||= {}
|
90
97
|
params[:user][:role_ids] ||= []
|
91
98
|
if @user.update_attributes(params[:user])
|
92
|
-
return update_permissions
|
99
|
+
return update_permissions
|
100
|
+
end
|
101
|
+
else # Standard update
|
102
|
+
if @user.update_attributes(params[:user])
|
103
|
+
respond_to do |format|
|
104
|
+
format.html do
|
105
|
+
flash[:notice] = translate('muck.users.user_update_sucess')
|
106
|
+
redirect_to admin_users_path
|
107
|
+
end
|
108
|
+
format.js { render :template => 'admin/users/row', :layout => false }
|
109
|
+
end
|
110
|
+
else
|
111
|
+
respond_to do |format|
|
112
|
+
format.html { render :template => 'admin/users/edit' }
|
113
|
+
format.js { output_admin_messages(@user) }
|
114
|
+
end
|
93
115
|
end
|
116
|
+
return
|
94
117
|
end
|
95
|
-
flash[:notice] = message
|
96
|
-
output_admin_messages(@user)
|
97
|
-
end
|
98
118
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
self.current_user = @user
|
103
|
-
flash[:notice] = t("muck.users.user_enabled")
|
104
|
-
else
|
105
|
-
flash[:error] = t("muck.users.user_enable_problem")
|
119
|
+
respond_to do |format|
|
120
|
+
format.html { redirect_to admin_users_path }
|
121
|
+
format.js { output_admin_messages(@user) }
|
106
122
|
end
|
107
|
-
redirect_to :action => 'index'
|
108
123
|
end
|
109
124
|
|
110
|
-
def
|
111
|
-
@user
|
112
|
-
|
113
|
-
flash[:notice] = t("users.user_disabled")
|
125
|
+
def destroy
|
126
|
+
if @user.admin?
|
127
|
+
flash[:notice] = translate('muck.users.cant_delete_admin')
|
114
128
|
else
|
115
|
-
|
129
|
+
@user.destroy
|
130
|
+
flash[:notice] = translate('muck.users.user_successfully_deleted', :login => @user.login)
|
116
131
|
end
|
117
|
-
redirect_to :action => 'index'
|
118
|
-
end
|
119
|
-
|
120
|
-
def destroy
|
121
|
-
@user.destroy
|
122
132
|
respond_to do |format|
|
123
|
-
format.html
|
124
|
-
|
125
|
-
|
133
|
+
format.html { redirect_to admin_users_path }
|
134
|
+
format.js do
|
135
|
+
if @user.admin?
|
136
|
+
output_admin_messages
|
137
|
+
else
|
138
|
+
render :js => "jQuery('##{@user.dom_id('row')}').fadeOut();"
|
139
|
+
end
|
126
140
|
end
|
127
|
-
format.xml { head :ok }
|
128
|
-
format.js { render :js => "jQuery('##{@user.dom_id('row')}').fadeOut();" }
|
129
141
|
end
|
130
142
|
end
|
131
143
|
|
@@ -137,12 +149,18 @@ class Admin::Muck::UsersController < Admin::Muck::BaseController
|
|
137
149
|
|
138
150
|
def update_permissions(message = '')
|
139
151
|
flash[:notice] = message unless message.blank?
|
140
|
-
|
152
|
+
respond_to do |format|
|
153
|
+
format.html { redirect_to admin_users_path }
|
154
|
+
format.js { render :template => 'admin/users/row', :layout => false }
|
155
|
+
end
|
141
156
|
end
|
142
157
|
|
143
|
-
def update_activate(message)
|
144
|
-
flash[:notice] = message
|
145
|
-
|
158
|
+
def update_activate(message = '')
|
159
|
+
flash[:notice] = message unless message.blank?
|
160
|
+
respond_to do |format|
|
161
|
+
format.html { redirect_to admin_users_path }
|
162
|
+
format.js { render :template => 'admin/users/row', :layout => false }
|
163
|
+
end
|
146
164
|
end
|
147
165
|
|
148
166
|
def get_user
|
@@ -8,5 +8,6 @@
|
|
8
8
|
</td>
|
9
9
|
<td><%= link_to(translate('muck.users.change_permissions'), permissions_admin_user_path(user), { :title => translate('muck.users.change_permissions_for', :user => user.full_name), :class => 'dialog-pop' }) %></td>
|
10
10
|
<td id="<%=user.dom_id('link')%>"><%= render :partial => 'admin/users/activate', :locals => { :user => user } %></td>
|
11
|
+
<td><%= link_to(t("muck.users.edit"), edit_admin_user_path(user.id)) -%></td>
|
11
12
|
<td><%= link_to(t("muck.general.delete"), admin_user_path(user.id), { :title => t('muck.users.delete_this_user'), :class => 'delete-user ajax-delete' }) -%></td>
|
12
13
|
</tr>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div id="edit-user" class="common-form">
|
2
|
+
<h1><%= t('muck.users.update_user_admin') %></h1>
|
3
|
+
|
4
|
+
<% custom_form_for @user, :url => admin_user_path(@user), :html => {:id => "edit-user-form", :name => 'edit-user-form', :method => :put, :multipart => true } do |f| -%>
|
5
|
+
|
6
|
+
<%= output_errors(t('muck.users.problem_editing_account'), {:class => 'help-box'}, @user) %>
|
7
|
+
|
8
|
+
<%= f.text_field :email, { :label => t('muck.users.email_address'),
|
9
|
+
:tip => t('muck.users.email_help') } -%>
|
10
|
+
<%= f.text_field :first_name, { :label => t('muck.users.first_name') } %>
|
11
|
+
<%= f.text_field :last_name, { :label => t('muck.users.last_name') } %>
|
12
|
+
<div class="button form-row">
|
13
|
+
<%= f.submit t('muck.general.save') %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div id="change-password" class="common-form">
|
20
|
+
<h2><%= t('muck.users.change_password') %></h2>
|
21
|
+
<% custom_form_for @user, :url => admin_user_path(@user), :html => { :id => "change-password-form", :name => 'change-password-form', :method => :put } do |f| %>
|
22
|
+
<%= f.password_field :password, { :label => t('muck.users.password'),
|
23
|
+
:tip => t('muck.users.password_help')} -%>
|
24
|
+
<%= f.password_field :password_confirmation, { :label => t('muck.users.confirm_password'),
|
25
|
+
:tip => t('muck.users.password_confirmation_help') } -%>
|
26
|
+
<div class="button form-row">
|
27
|
+
<%= submit_tag t('muck.users.change_password'), :class => 'button' %>
|
28
|
+
</div>
|
29
|
+
<% end -%>
|
30
|
+
</div>
|
data/config/muck_users_routes.rb
CHANGED
@@ -2,7 +2,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
2
2
|
|
3
3
|
# users
|
4
4
|
map.resources :users, :controller => 'muck/users',
|
5
|
-
:member => { :
|
5
|
+
:member => { :welcome => :get, :activation_instructions => :get },
|
6
6
|
:collection => { :is_login_available => :post, :is_email_available => :post, :login_search => :get }
|
7
7
|
|
8
8
|
map.with_options(:controller => 'muck/users') do |users|
|
data/locales/en.yml
CHANGED
@@ -12,6 +12,7 @@ en:
|
|
12
12
|
access_required_warning: Site access is currently restricted. You need a valid access code to sign up.
|
13
13
|
login_out_success: You have been logged out.
|
14
14
|
sign_out_title: Sign Out
|
15
|
+
cant_disable_admin: Can't disable an administrator. Please remove the user from the administrator role and try again.
|
15
16
|
already_registered: Already a member?
|
16
17
|
activation_not_found: Activation code not found. Please try creating a new account.
|
17
18
|
use_limit_tip: Enter the number of times the access code can be used.
|
@@ -39,6 +40,7 @@ en:
|
|
39
40
|
access_code_delete_error: An error occured while trying to delete the access code
|
40
41
|
access_code_fullfill_invites: Fulfill Invite Requests
|
41
42
|
access_code_unlimited: Unlimited
|
43
|
+
user_update_sucess: User was successfully updated
|
42
44
|
welcome: Welcome
|
43
45
|
bulk_access_codes_created: Bulk access codes created and emailed to {{email_count}} emails.
|
44
46
|
users_in_role: "Users in role: {{role}}"
|
@@ -62,9 +64,7 @@ en:
|
|
62
64
|
access_code_delete_link: Delete Access Code
|
63
65
|
request_access_code: Request Access Code
|
64
66
|
first_name: First Name
|
65
|
-
username: Username
|
66
67
|
forgot_username: Forgot Username
|
67
|
-
updated_permissions: Updated Permissions
|
68
68
|
account_activated: Your account has been activated! You can now login.
|
69
69
|
already_logged_in: You are already logged in and don't need to recover your password.
|
70
70
|
email_invalid: Invalid email
|
@@ -151,6 +151,7 @@ en:
|
|
151
151
|
access_code_expires: Expires
|
152
152
|
user_successfully_deleted: User {{login}} was successfully deleted.
|
153
153
|
application_base_url_not_set: Please set application_base_url in global_config.yml
|
154
|
+
cant_delete_admin: You can't delete a user that is in the admin role. Remove the user from the administrator role and then try again. Please be careful when deleting administrators. If you delete all administrator accounts you will no longer be able to login to the administration system.
|
154
155
|
access_code_update_problem: There was a problem updating the access code.
|
155
156
|
user_not_deactivated_error: Could not deactivate user
|
156
157
|
total_users: "Total Users: {{total}}"
|
@@ -198,6 +199,7 @@ en:
|
|
198
199
|
user_update: You're user information has been updated.
|
199
200
|
update_profile: Update your profile
|
200
201
|
update_user: Update your user information
|
202
|
+
update_user_admin: Update User
|
201
203
|
choose_member_name: Member Name
|
202
204
|
access_denied: You don't have permission to access the requested page.
|
203
205
|
username_available: Username available
|
data/muck-users.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-users}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin"]
|
@@ -63,13 +63,13 @@ Gem::Specification.new do |s|
|
|
63
63
|
"app/views/admin/users/_table.html.erb",
|
64
64
|
"app/views/admin/users/_user_navigation.html.erb",
|
65
65
|
"app/views/admin/users/do_search.html.erb",
|
66
|
+
"app/views/admin/users/edit.html.erb",
|
66
67
|
"app/views/admin/users/inactive.html.erb",
|
67
68
|
"app/views/admin/users/inactive_emails.html.erb",
|
68
69
|
"app/views/admin/users/index.html.erb",
|
69
70
|
"app/views/admin/users/permissions.html.erb",
|
71
|
+
"app/views/admin/users/row.js.erb",
|
70
72
|
"app/views/admin/users/search.html.erb",
|
71
|
-
"app/views/admin/users/update_activate.js.erb",
|
72
|
-
"app/views/admin/users/update_permissions.js.erb",
|
73
73
|
"app/views/password_resets/edit.html.erb",
|
74
74
|
"app/views/password_resets/new.html.erb",
|
75
75
|
"app/views/user_mailer/access_code.text.html.erb",
|
@@ -17,6 +17,7 @@ class Admin::Muck::UsersControllerTest < ActionController::TestCase
|
|
17
17
|
|
18
18
|
context "logged in as admin" do
|
19
19
|
setup do
|
20
|
+
@user = Factory(:user)
|
20
21
|
@admin = Factory(:user)
|
21
22
|
@admin_role = Factory(:role, :rolename => 'administrator')
|
22
23
|
@admin.roles << @admin_role
|
@@ -54,8 +55,77 @@ class Admin::Muck::UsersControllerTest < ActionController::TestCase
|
|
54
55
|
end
|
55
56
|
should_respond_with :success
|
56
57
|
should_render_template :table
|
57
|
-
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "GET edit" do
|
61
|
+
setup do
|
62
|
+
get :edit, :id => @user.to_param
|
63
|
+
end
|
64
|
+
should_respond_with :success
|
65
|
+
should_render_template :edit
|
66
|
+
end
|
67
|
+
|
68
|
+
context "PUT to update" do
|
69
|
+
setup do
|
70
|
+
put :update, :id => @user.to_param, :user => { :email => 'testguy@example.com' }, :format => 'js'
|
71
|
+
end
|
72
|
+
should_respond_with :success
|
73
|
+
should "not have errors" do
|
74
|
+
assert assigns(:user).errors.empty?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "fail on PUT to update" do
|
79
|
+
setup do
|
80
|
+
put :update, :id => @user.to_param, :user => { :email => nil }, :format => 'js'
|
81
|
+
end
|
82
|
+
should_respond_with :success
|
83
|
+
should "have errors on access code's 'email' field" do
|
84
|
+
assert assigns(:user).errors.on(:email)
|
85
|
+
end
|
86
|
+
end
|
58
87
|
|
88
|
+
context "PUT to update - deactivate user" do
|
89
|
+
setup do
|
90
|
+
put :update, :id => @user.to_param, :deactivate => true, :format => 'js'
|
91
|
+
end
|
92
|
+
should_respond_with :success
|
93
|
+
should "deactivate the user" do
|
94
|
+
assert !User.find(@user.to_param).active?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "PUT to update - activate user" do
|
99
|
+
setup do
|
100
|
+
put :update, :id => @user.to_param, :activate => true, :format => 'js'
|
101
|
+
end
|
102
|
+
should_respond_with :success
|
103
|
+
should "activate the user" do
|
104
|
+
assert User.find(@user.to_param).active?
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "PUT to update - update roles" do
|
109
|
+
setup do
|
110
|
+
@new_role = Factory(:role)
|
111
|
+
put :update, :id => @user.to_param, :update_roles => true, :user => { :role_ids => [ @new_role.id ] }, :format => 'js'
|
112
|
+
end
|
113
|
+
should_respond_with :success
|
114
|
+
should "give user the new role" do
|
115
|
+
assert User.find(@user.to_param).has_role?(@new_role.rolename)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "PUT to update - remove all roles" do
|
120
|
+
setup do
|
121
|
+
put :update, :id => @user.to_param, :update_roles => true, :format => 'js'
|
122
|
+
end
|
123
|
+
should_respond_with :success
|
124
|
+
should "remove the user from all roles" do
|
125
|
+
assert User.find(@user.to_param).roles.empty?
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
59
129
|
context 'on DELETE to :destroy' do
|
60
130
|
setup do
|
61
131
|
@user = Factory(:user)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-users
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -119,13 +119,13 @@ files:
|
|
119
119
|
- app/views/admin/users/_table.html.erb
|
120
120
|
- app/views/admin/users/_user_navigation.html.erb
|
121
121
|
- app/views/admin/users/do_search.html.erb
|
122
|
+
- app/views/admin/users/edit.html.erb
|
122
123
|
- app/views/admin/users/inactive.html.erb
|
123
124
|
- app/views/admin/users/inactive_emails.html.erb
|
124
125
|
- app/views/admin/users/index.html.erb
|
125
126
|
- app/views/admin/users/permissions.html.erb
|
127
|
+
- app/views/admin/users/row.js.erb
|
126
128
|
- app/views/admin/users/search.html.erb
|
127
|
-
- app/views/admin/users/update_activate.js.erb
|
128
|
-
- app/views/admin/users/update_permissions.js.erb
|
129
129
|
- app/views/password_resets/edit.html.erb
|
130
130
|
- app/views/password_resets/new.html.erb
|
131
131
|
- app/views/user_mailer/access_code.text.html.erb
|