This commit is contained in:
gopesht 2014-03-13 21:12:13 +00:00
commit 91dc475eb2
6 changed files with 69 additions and 3 deletions

View file

@ -16,4 +16,15 @@ class Admin::UsersController < ApplicationController
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

View file

@ -0,0 +1,38 @@
class PasswordsController < Devise::PasswordsController
skip_before_filter :verify_user
def new
super
end
def edit
super
end
def update
@user = User.find_by_reset_password_token(params[:user][:reset_password_token])
logger.debug "#{@user.email}"
password_changed = false
if !params[:user][:password].nil?
if !params[:user][:password].empty?
password_changed = true
else
params[:user].delete :password
params[:user].delete :password_confirmation
end
end
if password_changed
successfully_updated = @user.reset_password!(params[:user][:password],params[:user][:password_confirmation])
else
redirect_to session[:return_to], :notice => "Blank Field Entered" and return
end
if successfully_updated
redirect_to root_path, :notice => "Your password is changed" and return
else
redirect_to session[:return_to] and return
end
end
end

View file

@ -13,7 +13,7 @@
%b ID
%th
%b Title
- if @conference.call_for_papers.rating != 0
- if !@conference.call_for_papers.blank? && @conference.call_for_papers.rating != 0
%th
%b Rating
%th

View file

@ -24,6 +24,7 @@
%b Roles
%th
%th
%th
- @users.each do |user|
- person = Person.find_person_by_user_id(user.id)
%tr
@ -71,6 +72,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() {

View file

@ -1,7 +1,12 @@
Osem::Application.routes.draw do
devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts'
devise_for :users, :controllers => { :registrations => :registrations,:passwords=>:passwords }, :path => 'accounts'
# resources :passwords do
# get "passwords/new" => "passwords#new"
# get "/passwords/:id/edit" => "passwords#edit"
# end
namespace :admin do
resources :users
resources :people

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe "passwords/update.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end