From e51cf148d2a5910c224f34c5448070f122e75c1f Mon Sep 17 00:00:00 2001 From: gopesht Date: Sun, 9 Mar 2014 02:33:49 +0530 Subject: [PATCH 1/3] Check for call_for_papers object. When call_for_papers object is nil then the previous check throws an error for check at line no 16. So I modified the check to see that first the call_for papers object exsist for current conference object an the rest follow. --- app/views/admin/events/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ad544a117f5952c82d5086bd25d9c63d246fc427 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Sun, 9 Mar 2014 11:58:57 +0530 Subject: [PATCH 2/3] Admin able to delete every other user except admins(feature) --- app/controllers/admin/users_controller.rb | 11 +++++++++++ app/views/admin/users/index.html.haml | 7 +++++++ 2 files changed, 18 insertions(+) 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/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() { From 697fc08e18778e803d86cec11790047d1a74085d Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 14 Mar 2014 01:55:47 +0530 Subject: [PATCH 3/3] Fixed forgot password, no redirect loop know while resetting forgotten password --- app/controllers/passwords_controller.rb | 38 ++++++++++++++++++++ config/routes.rb | 9 +++-- spec/views/passwords/update.html.erb_spec.rb | 5 +++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 app/controllers/passwords_controller.rb create mode 100644 spec/views/passwords/update.html.erb_spec.rb 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/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