parent
b871285c75
commit
fbbc0edebe
@ -3,8 +3,11 @@ module Admin
|
|||||||
class CandidateController < AdminController
|
class CandidateController < AdminController
|
||||||
before_action :collect_quizzes, except: [:login, :auth]
|
before_action :collect_quizzes, except: [:login, :auth]
|
||||||
|
|
||||||
|
helper_method :sort_column
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@candidates = policy_scope Candidate.order(:name)
|
@candidates = policy_scope Candidate.order("#{sort_column} #{sort_direction}")
|
||||||
|
.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@ -65,5 +68,9 @@ module Admin
|
|||||||
CandidateMailer.welcome(candidate).deliver_later
|
CandidateMailer.welcome(candidate).deliver_later
|
||||||
RecruiterMailer.candidate_created(candidate).deliver_later
|
RecruiterMailer.candidate_created(candidate).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sort_column
|
||||||
|
Candidate.column_names.include?(params[:sort]) ? params[:sort] : 'name'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
module Admin
|
module Admin
|
||||||
class ResultController < AdminController
|
class ResultController < AdminController
|
||||||
helper_method :sort_column, :sort_direction
|
helper_method :sort_column
|
||||||
|
|
||||||
# TODO: change context from Candidate to Quiz
|
# TODO: change context from Candidate to Quiz
|
||||||
# bypass pundit lockdowns until completed
|
# bypass pundit lockdowns until completed
|
||||||
@ -30,9 +30,5 @@ module Admin
|
|||||||
def sort_column
|
def sort_column
|
||||||
Candidate.column_names.include?(params[:sort]) ? params[:sort] : 'completed_at'
|
Candidate.column_names.include?(params[:sort]) ? params[:sort] : 'completed_at'
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_direction
|
|
||||||
%w(asc desc).include?(params[:direction]) ? params[:direction] : 'desc'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,8 @@ class AdminController < ApplicationController
|
|||||||
after_action :verify_authorized, except: :index
|
after_action :verify_authorized, except: :index
|
||||||
after_action :verify_policy_scoped, only: :index
|
after_action :verify_policy_scoped, only: :index
|
||||||
|
|
||||||
|
helper_method :sort_direction
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
@current_user ||= User.find_by(id: session[:user]) if session[:user]
|
@current_user ||= User.find_by(id: session[:user]) if session[:user]
|
||||||
end
|
end
|
||||||
@ -16,6 +18,10 @@ class AdminController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def sort_direction
|
||||||
|
%w(asc desc).include?(params[:direction]) ? params[:direction] : 'desc'
|
||||||
|
end
|
||||||
|
|
||||||
def authorize_user
|
def authorize_user
|
||||||
session[:request] = request.fullpath
|
session[:request] = request.fullpath
|
||||||
redirect_to admin_login_path unless current_user
|
redirect_to admin_login_path unless current_user
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
<table cellspacing="0" cellpadding="0">
|
<table cellspacing="0" cellpadding="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Candidate</th>
|
<th><%= sortable "name", "Candidate" %></th>
|
||||||
<th>Test ID</th>
|
<th><%= sortable "test_hash", "Test ID" %></th>
|
||||||
<th>Email</th>
|
<th><%= sortable "email" %></th>
|
||||||
<th>Experience</th>
|
<th><%= sortable "experience" %></th>
|
||||||
<th>Progress</th>
|
<th>Progress</th>
|
||||||
<th>Completed</th>
|
<th><%= sortable "completed_at", "Completed" %></th>
|
||||||
<th>Reminded</th>
|
<th><%= sortable "reminded" %></th>
|
||||||
<th>Interview?</th>
|
<th>Interview?</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -36,4 +36,5 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
<%= paginate @candidates %>
|
||||||
</main>
|
</main>
|
||||||
|
Loading…
Reference in New Issue
Block a user