diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b30b1598..8ccd0882 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb new file mode 100644 index 00000000..4f0104ba --- /dev/null +++ b/app/controllers/passwords_controller.rb @@ -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 \ No newline at end of file diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index fc50cbbe..04d8267a 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -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 diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index 030ed138..74a8ffe4 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -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() { diff --git a/config/routes.rb b/config/routes.rb index 7103e699..e19942ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/views/passwords/update.html.erb_spec.rb b/spec/views/passwords/update.html.erb_spec.rb new file mode 100644 index 00000000..87943554 --- /dev/null +++ b/spec/views/passwords/update.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "passwords/update.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end