recruitment/app/controllers/recruitments_controller.rb

113 lines
2.4 KiB
Ruby
Raw Normal View History

2017-12-21 19:41:50 +00:00
class RecruitmentsController < PseudoSessionController
before_filter :set_key_for_this
before_filter :load_profile, :except => ["newprofile", "createprofile"]
before_filter :is_user_authorized?
layout :get_layout
def index
end
def firstruncheck
if @profile.nil?
redirect_to select_profile_path
else
redirect_to mydashboard_path
end
end
def select_profile
end
def newprofile
@profile = RecruitProfile.new
if params[:type] == "1"
@profile.build_employee_profile
elsif params[:type] == "2"
@profile.build_employer_profile
end
end
def createprofile
profile = RecruitProfile.create(profile_params)
redirect_to mydashboard_path
end
def recruitment_dashboard
@jobsposted = @profile.profile.recruitment_jobs
@page = "/#{I18n.locale.to_s}" + Page.where(:module => "recruitment").first.url rescue "#"
end
def editprofile
end
def updateprofile
@profile.update_attributes(profile_params)
redirect_to mydashboard_path
end
def addjob
@job = RecruitmentJob.new
end
def editjob
@job = RecruitmentJob.find(params[:id])
end
def createjob
job = RecruitmentJob.create(recruitment_job_params)
redirect_to mydashboard_path
end
def updatejob
job = RecruitmentJob.find(params[:id])
job.update_attributes(recruitment_job_params)
redirect_to mydashboard_path
end
def markfilled
job = RecruitmentJob.find(params[:id])
if job.employer_profile_id.to_s == @profile.profile.id.to_s
job.filled = true
job.save
end
redirect_to mydashboard_path
end
def unmarkfilled
job = RecruitmentJob.find(params[:id])
if job.employer_profile_id.to_s == @profile.profile.id.to_s
job.filled = false
job.save
end
redirect_to mydashboard_path
end
def deletejob
job = RecruitmentJob.find(params[:id])
job.destroy
redirect_to mydashboard_path
end
private
def get_layout
"recruit"
end
def load_profile
@profile = RecruitProfile.where(:pseudo_member_id => current_pseudo_user.user_name).first rescue nil
end
def profile_params
params.require(:recruit_profile).permit!
end
def recruitment_job_params
par = params.require(:recruitment_job).permit!
par[:skills] = par[:skills].split(",") if par[:skills].present?
par[:skills].collect!{|sk| sk.strip}
par
2017-12-21 19:41:50 +00:00
end
end