Skip to content

Commit

Permalink
Merge pull request #51 from gopesht/delete_users
Browse files Browse the repository at this point in the history
Admin able to delete users except admins
  • Loading branch information
hennevogel committed Apr 9, 2014
2 parents 8f222db + d38a133 commit c261876
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/controllers/admin/users_controller.rb
Expand Up @@ -15,5 +15,17 @@ def update
user = User.find(params[:id])
user.update_attributes!(params[:user])
redirect_to admin_users_path, :notice => "Updated #{user.email}"
end

def delete
@user = User.find(params[:id])
end

def destroy
@user = User.find(params[:id])
@user.destroy
redirect_to admin_users_path, :notice => "User got deleted"

end

end
7 changes: 7 additions & 0 deletions app/views/admin/users/index.html.haml
Expand Up @@ -23,6 +23,7 @@
%b Roles
%th
%th
%th
- @users.each do |user|
- person = Person.find_person_by_user_id(user.id)
%tr
Expand Down Expand Up @@ -69,6 +70,12 @@
"data-html" => "true",
"data-content" => user.popup_details,
"data-original-title" => ""
%td
- if current_user.id == user.id or user.role_ids.include? 3
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
- else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
:javascript
$(document).ready(function() {
Expand Down

0 comments on commit c261876

Please sign in to comment.