recommendations added and minor changes done asked by nthu

This commit is contained in:
Harry Bomrah 2018-01-11 20:21:16 +08:00
parent 27865c840f
commit 280fb5407e
16 changed files with 385 additions and 27 deletions

View File

@ -2,7 +2,7 @@ class RecruitmentsController < PseudoSessionController
include ActionView::Helpers::TextHelper
before_filter :set_key_for_this, :except => ["index", "show"]
before_filter :load_profile, :except => ["newprofile", "createprofile", "index", "show", "advancedform"]
before_filter :is_user_authorized?, :except => ["index", "show", "advancedform"]
before_filter :is_user_authorized?, :except => ["index", "show", "advancedform", "write_recommendation", "create_recommendation"]
layout :get_layout
def index
@ -147,7 +147,7 @@ class RecruitmentsController < PseudoSessionController
end
skills = profile.skills.collect{|skill| {"skill-name" => skill}} if !profile.skills.empty?
infos = []
["autobiography", "resume_content", "recommendation1_info", "recommendation2_info"].each do |t|
["autobiography", "resume_content"].each do |t|
if !profile.send(t).nil? && profile.send(t) != ""
infos << {
"title" => t("recruitment.#{t}"),
@ -155,6 +155,16 @@ class RecruitmentsController < PseudoSessionController
}
end
end
recommendations = []
profile.employee_recommendations.desc(:creted_at).each do |rec|
recommendations << {
"name" => rec.name,
"email" => rec.email,
"rec-letter" => rec.info
}
end
if profile.experience_years == 0 && profile.experience_months == 0
experience = t("recruitment.fresher")
else
@ -163,6 +173,7 @@ class RecruitmentsController < PseudoSessionController
{
"skills" => skills,
"infos" => infos,
"recommendations" => recommendations,
"data" => {
"name" => rp.name,
"job-title" => profile.desired_job_title,
@ -185,6 +196,7 @@ class RecruitmentsController < PseudoSessionController
"language" => profile.languages,
"workingtime-title" => t("recruitment.workingtime_title"),
"workingtime" => (!profile.working_time.nil? && profile.working_time != "" ? t("recruitment.working_time.#{profile.working_time}") : t("recruitment.not_available")),
"recommendation-title" => t("recruitment.recommendation")
}
}
end
@ -241,6 +253,13 @@ class RecruitmentsController < PseudoSessionController
end
end
end
if job.max_salary > job.min_salary
range = (job.min_salary * 1000).to_s + " ~ " + (job.max_salary * 1000).to_s + " / Month "
elsif job.max_salary == job.min_salary
range = t("recruitment.not_available")
elsif job.max_salary < job.min_salary
range = (job.min_salary * 1000).to_s + " ~ #{t('recruitment.salary.type1')} / Month"
end
{
"infos" => infos,
"data" => {
@ -256,10 +275,14 @@ class RecruitmentsController < PseudoSessionController
"skills" => skills,
"experience-title" => t("recruitment.experience_title"),
"experience" => experience,
"min-qualification-title" => t("recruitment.min_qualification"),
"min-qualification" => (!job.academic_type.nil? && job.academic_type != "" ? t("recruitment.academic_type.#{job.academic_type}") : t("recruitment.not_available")),
"qualification-title" => t("recruitment.qualification"),
"qualification" => (!job.academic_requirement.nil? && job.academic_requirement != "" ? simple_format(job.academic_requirement) : t("recruitment.not_available")),
"salary-title" => t("recruitment.salary-title"),
"salary" => (!job.salary.nil? && job.salary != "" ? t("recruitment.salary.#{job.salary}") : t("recruitment.not_available")),
"salary-range" => t("recruitment.salary_range"),
"range" => range,
"travel-title" => t("recruitment.travel"),
"travel" => (!job.travel_assignment.nil? && job.travel_assignment != "" ? t("recruitment.travel_assignment.#{job.travel_assignment}") : t("recruitment.not_available")),
"joining-title" => t("recruitment.joining"),
@ -423,6 +446,41 @@ class RecruitmentsController < PseudoSessionController
end
end
def employee_recommendation
@recommendations = @profile.profile.employee_recommendations.desc(:created_at)
if request.request_method == "POST"
token = rand(10**8).to_s
eprofile = @profile.profile
eprofile.recommendation_tokens << token
eprofile.save
url = "http://#{request.host_with_port}/recruit/#{@profile.uid}/write_recommendation?token=#{token}"
data = {"url" => url, "letter" => params[:request_letter], "referral_name" => params[:referral_name], "name" => @profile.name, "respected" => t("recruitment.respected"), "recommendation_link" => t("recruitment.recommendation_link"), "yours_sincerely" => t("recruitment.yours_sincerely")}
email = Email.new
email.mail_to = params[:referral_email]
email.mail_subject = t("recruitment.recommendation_subject")
email.template = "recruitments/recommendation_email.html.erb"
email.template_data = data
email.deliver
redirect_to employee_recommendation_path
end
end
def write_recommendation
@profile = RecruitProfile.where(:uid => params[:id]).first
@is_written = @profile.profile.employee_recommendations.where(:employee_recommendation_token => params[:token]).count > 0
@recommendation = EmployeeRecommendation.new
end
def create_recommendation
rec = EmployeeRecommendation.create(recommendation_params)
end
def delete_employee_recommendation
rec = EmployeeRecommendation.find(params[:id])
rec.destroy
redirect_to employee_recommendation_path
end
def edit_employee_experience
@experience = EmployeeExperience.find(params[:id])
end
@ -435,10 +493,12 @@ class RecruitmentsController < PseudoSessionController
def addjob
@job = RecruitmentJob.new
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
end
def editjob
@job = RecruitmentJob.find(params[:id])
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
end
def createjob
@ -577,4 +637,8 @@ class RecruitmentsController < PseudoSessionController
par
end
def recommendation_params
params.require(:employee_recommendation).permit!
end
end

View File

@ -24,11 +24,10 @@ class EmployeeProfile
field :working_time #type1 -> day shift type2 -> night shift
field :skills, type: Array, :default => []
field :languages
field :recommendation1_info
field :recommendation2_info
field :experience_years, type: Integer, :default => 0
field :experience_months, type: Integer, :default => 0
field :introduction, localize: true
field :recommendation_tokens, type: Array, :default => []
mount_uploader :resume, AssetUploader
@ -39,6 +38,7 @@ class EmployeeProfile
has_many :employee_academics
has_many :employee_experiences
has_many :employee_job_applications
has_many :employee_recommendations
scope :job_seekers, ->{where(:active => true)}

View File

@ -0,0 +1,11 @@
class EmployeeRecommendation
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :email
field :info
field :employee_recommendation_token
belongs_to :employee_profile
end

View File

@ -3,12 +3,13 @@ class RecruitmentJob
include Mongoid::Timestamps
include Slug
field :post_type #type1 => Job, type2 => Internship, type3 => Exchange
field :job_title, as: :slug_title, localize: true
field :job_description, localize: true
field :responsibility, localize: true
field :other_conditions, localize: true
field :salary #type1 => negotiable type2 => according to company rules type3 => monthly salary
field :salary #type1 => negotiable type2 => according to company rules
field :travel_assignment #type1 => Need to travel, type2 => occasionally, type3 => travelling not required
field :working_time #type1 => Day Shift, type2 => Night Shift
field :holiday_system #type1 => According to Company Rules, type2 => other
@ -23,6 +24,10 @@ class RecruitmentJob
field :category
field :location_of_work
field :industrial_area
field :academic_type #type1 -> bachelors, type2 -> masters, type3 -> phd, type4 -> course
field :min_salary, type: Integer, :default => 0
field :max_salary, type: Integer, :default => 0
field :filled, type: Boolean, :default => false

View File

@ -12,6 +12,7 @@
<li role="presentation" class="<%= params[:action] == "employee_academics" ? "active" : "" %>"><a href="<%= employee_academics_path %>"><%= t("recruitment.academics") %></a></li>
<li role="presentation" class="<%= params[:action] == "employee_portfolio" ? "active" : "" %>"><a href="<%= employee_portfolio_path %>"><%= t("recruitment.portfolio") %></a></li>
<li role="presentation" class="<%= params[:action] == "employee_experience" ? "active" : "" %>"><a href="<%= employee_experience_path %>"><%= t("recruitment.experience") %></a></li>
<li role="presentation" class="<%= params[:action] == "employee_recommendation" ? "active" : "" %>"><a href="<%= employee_recommendation_path %>"><%= t("recruitment.recommendation") %></a></li>
<% end %>
</ul>
<% if params[:action] == "recruitment_dashboard" && @profile.is_employer? %>

View File

@ -69,8 +69,18 @@
<label for="recruitment_job_salary_type2" class="control-label radio-label">
<%= f.radio_button :salary, "type2" %> <%= t("recruitment.salary.type2") %>
</label>
<label for="recruitment_job_salary_type3" class="control-label radio-label">
<%= f.radio_button :salary, "type3" %> <%= t("recruitment.salary.type3") %>
</div>
</div>
<!-- salary range -->
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.salary_range") %></label>
<div class="col-sm-8">
<label for="recruitment_job_min_salary" class="control-label radio-label">
<%= t("recruitment.min_salary") %> <%= f.number_field :min_salary %> <%= t("recruitment.thousands") + " / " + t("recruitment.month") %>
</label>
<label for="recruitment_job_max_salary" class="control-label radio-label">
<%= t("recruitment.max_salary") %> <%= f.number_field :max_salary %> <%= t("recruitment.thousands") + " / " + t("recruitment.month") %>
</label>
</div>
</div>
@ -151,41 +161,49 @@
<hr>
<!-- Work Type -->
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.worktype_title") %></label>
<!-- <div class="form-group">
<label class="col-sm-2 control-label"><%#= t("recruitment.worktype_title") %></label>
<div class="col-sm-8">
<label for="recruitment_job_work_type_type1" class="control-label radio-label">
<%= f.radio_button :work_type, "type1" %> <%= t("recruitment.work_type.type1") %>
<%#= f.radio_button :work_type, "type1" %> <%#= t("recruitment.work_type.type1") %>
</label>
<label for="recruitment_job_work_type_type2" class="control-label radio-label">
<%= f.radio_button :work_type, "type2" %> <%= t("recruitment.work_type.type2") %>
<%#= f.radio_button :work_type, "type2" %> <%#= t("recruitment.work_type.type2") %>
</label>
<label for="recruitment_job_work_type_type3" class="control-label radio-label">
<%= f.radio_button :work_type, "type3" %> <%= t("recruitment.work_type.type3") %>
<%#= f.radio_button :work_type, "type3" %> <%#= t("recruitment.work_type.type3") %>
</label>
<label for="recruitment_job_work_type_type4" class="control-label radio-label">
<%= f.radio_button :work_type, "type4" %> <%= t("recruitment.work_type.type4") %>
<%#= f.radio_button :work_type, "type4" %> <%#= t("recruitment.work_type.type4") %>
</label>
<label for="recruitment_job_work_type_type5" class="control-label radio-label">
<%= f.radio_button :work_type, "type5" %> <%= t("recruitment.work_type.type5") %>
<%#= f.radio_button :work_type, "type5" %> <%#= t("recruitment.work_type.type5") %>
</label>
</div>
</div>
</div> -->
<!-- Work Experience -->
<div class="form-group">
<%= f.label :work_experience_years, t("recruitment.work_experience"), :class => "col-sm-2 control-label" %>
<div class="col-sm-3">
<div class="col-sm-1">
<%= f.number_field :work_experience_years, :class => "form-control", :max => 50, :min => 0, :value => 0 %>
<label for="recruitment_job_work_experience_years"><%= t("recruitment.years") %></label>
</div>
<div class="col-sm-3">
<div class="col-sm-1">
<%= f.number_field :work_experience_months, :class => "form-control", :max => 11, :min => 0, :value => 0 %>
<label for="recruitment_job_work_experience_months"><%= t("recruitment.months") %></label>
</div>
</div>
<!-- Academic Type -->
<div class="form-group">
<%= f.label :academic_type, t("recruitment.academic_type"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= f.select :academic_type, @academic_types, {:include_blank => "Select Degree"},{:class => "form-control"} %>
</div>
</div>
<!-- Academic Req -->
<div class="form-group">
<%= f.label :academic_requirement, t("recruitment.academic_requirement"), :class => "col-sm-2 control-label" %>

View File

@ -1,3 +1,6 @@
<%= form_for @job, url: {:action => "createjob"}, html: {:class => "form-horizontal main-forms"} do |f| %>
<%= render :partial => "job_form", locals: {f: f} %>
<% end %>
<div id="dashboard-wrapper">
<%= render :partial => "dashboard_header" %>
<%= form_for @job, url: {:action => "createjob"}, html: {:class => "form-horizontal main-forms"} do |f| %>
<%= render :partial => "job_form", locals: {f: f} %>
<% end %>
</div>

View File

@ -0,0 +1,6 @@
<style type="text/css">
.alert{
text-align: center;
}
</style>
<div class="alert alert-success"> <%= t("recruitment.thank_you_recommendation") %></div>

View File

@ -1,3 +1,6 @@
<%= form_for @job, url: "/recruit/#{@job.id.to_s}/updatejob", html: {:class => "form-horizontal main-forms"} do |f| %>
<%= render :partial => "job_form", locals: {f: f} %>
<% end %>
<div id="dashboard-wrapper">
<%= render :partial => "dashboard_header" %>
<%= form_for @job, url: "/recruit/#{@job.id.to_s}/updatejob", html: {:class => "form-horizontal main-forms"} do |f| %>
<%= render :partial => "job_form", locals: {f: f} %>
<% end %>
</div>

View File

@ -175,10 +175,10 @@
<!-- Total Exp -->
<div class="form-group">
<%= fe.label :exprience_years, t("recruitment.total_exp"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<div class="col-sm-1">
<%= fe.number_field :experience_years, :class => "form-control", :max => 50, :min => 0 %> <%= t("recruitment.years") %>
</div>
<div class="col-sm-5">
<div class="col-sm-1">
<%= fe.number_field :experience_months, :class => "form-control", :max => 11, :min => 0 %> <%= t("recruitment.months") %>
</div>
</div>

View File

@ -0,0 +1,126 @@
<%= csrf_meta_tag %>
<%# content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%# end %>
<%# content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%# end %>
<style type="text/css">
.header-title{
text-align: center;
}
hr{
border-top: 1px solid #5c5c5c;
}
hr.dotted{
border-top: 1px dotted #5c5c5c;
}
.bootstrap-datetimepicker-widget ul{
list-style: none;
padding: 10px 25px;
text-align: center;
}
.bootstrap-datetimepicker-widget ul td,th{
cursor: pointer;
text-align: center;
}
.bootstrap-datetimepicker-widget ul td.old, td.new{
color: #cecece;
}
.bootstrap-datetimepicker-widget ul td:hover,th:hover{
background-color: #5c5c5c;
color: #fff;
}
.bootstrap-datetimepicker-widget span.month{
width: 50px;
}
.default_picker span.add-on{
padding: 3px;
margin-left: 5px;
cursor: pointer;
height: 20px;
width: 20px;
text-align: center;
}
</style>
<div id="dashboard-wrapper">
<%= render :partial => "dashboard_header" %>
<h3 class="header-title"><%= t("recruitment.recommendation") %></h3>
<hr>
<% @recommendations.each do |rec| %>
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.date") %></label>
<div class="col-sm-10">
<p class="form-control-static"><%= rec.created_at.strftime("%d %B %Y") rescue "" %></p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.referral_name") %></label>
<div class="col-sm-10">
<p class="form-control-static"><%= rec.name %></p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.referral_email") %></label>
<div class="col-sm-10">
<p class="form-control-static"><%= rec.email %></p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><%= t("recruitment.recommendation_letter") %></label>
<div class="col-sm-10">
<p class="form-control-static"><%= simple_format(rec.info) %></p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a data-method="delete" data-confirm="Are you sure?" href="/recruit/<%= rec.id.to_s %>/delete_employee_recommendation" class="btn btn-danger"><%= t("recruitment.delete") %></a>
</div>
</div>
</div>
<hr class="dotted">
<% end %>
<form class="form-horizontal" method="post" action="<%= employee_recommendation_path %>" >
<!-- name -->
<div class="form-group">
<label for="referral_name" class="col-sm-2 control-label"><%= t("recruitment.referral_name") %></label>
<div class="col-sm-5">
<input type="text" name="referral_name" id="referral_name" class="form-control">
</div>
</div>
<!-- email -->
<div class="form-group">
<label for="referral_email" class="col-sm-2 control-label"><%= t("recruitment.referral_email") %></label>
<div class="col-sm-5">
<input type="text" name="referral_email" id="referral_email" class="form-control">
</div>
</div>
<!-- Request letter -->
<div class="form-group">
<label for="request_letter" class="col-sm-2 control-label"><%= t("recruitment.request_letter") %></label>
<div class="col-sm-5">
<textarea name="request_letter" id="request_letter" cols="30" rows="10" class="form-control"><%= t("recruitment.request_letter_content") %></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= hidden_field_tag :authenticity_token, form_authenticity_token -%>
<input type="submit" value="<%= t("recruitment.request") %>" class="btn btn-primary">
</div>
</div>
</form>
</div>

View File

@ -0,0 +1,9 @@
<h4><%= @data["respected"] %> <%= @data["referral_name"] %></h4>
<p>
<%= @data["letter"] %>
</p>
<p>
<%= @data["recommendation_link"] %> <a href="<%= @data["url"] %>">Click Here</a>
</p>
<%= @data["yours_sincerely"] %>,<br />
<%= @data["name"] %>

View File

@ -0,0 +1,61 @@
<%# content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%# end %>
<%# content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<style type="text/css">
.head-title{
margin-bottom: 25px;
/*text-align: center;*/
}
hr{
border-top: 1px solid #5c5c5c;
}
.alert{
text-align: center;
}
</style>
<% if @profile.nil? %>
<div class="alert alert-danger"> <%= t("recruitment.user_not_found") %></div>
<% elsif !@profile.profile.recommendation_tokens.include?(params[:token]) %>
<div class="alert alert-danger"> <%= t("recruitment.referral_not_authorized") %></div>
<% elsif @is_written %>
<div class="alert alert-warning"> <%= t("recruitment.referral_already_recommended") %></div>
<% else %>
<h4 class="head-title">Please write a recommendation for <strong><%= @profile.name %></strong>.</h4>
<hr />
<%= form_for @recommendation, url: {"action" => "create_recommendation"}, :html => {:class => "form-horizontal main-forms"} do |f| %>
<div class="form-group">
<%= f.label :name, t("recruitment.name"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= f.text_field :name, :class => "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :email, t("recruitment.contact_email"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= f.text_field :email, :class => "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :info, t("recruitment.recommendation_letter"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= f.text_area :info, :rows => "10", :class => "form-control" %>
</div>
</div>
<div class="col-sm-offset-2 col-sm-10">
<%= f.hidden_field :employee_profile_id, :value => @profile.profile.id.to_s %>
<%= f.hidden_field :employee_recommendation_token, :value => params[:token] %>
<%= f.submit t("submit"), :class =>"btn btn-primary" %>
</div>
<% end %>
<% end %>

View File

@ -2,6 +2,31 @@ en:
module_name:
recruitment: Recruitment
recruitment:
min_qualification: Min Qualification
referral_already_recommended: Sorry! You already have written a recommendation for this user.
name: Name
thank_you_recommendation: Thank you for your recommendation.
contact_email: Contact Email
recommendation_letter: Recommendation Letter
date: Date
user_not_found: Sorry! The user you are looking for is not available.
referral_not_authorized: Sorry! You are not authorized to write a recommendation.
request_letter_content: "I am in the process of seeking a new position and am hoping that you will provide a reference for me. Having worked with you for many years, I believe that you can provide potential employers with information about my skills that will enhance my chances of getting the job."
respected: Respected
recommendation_link: Please click the following link to write a recommendation.
yours_sincerely: Yours Sincerely
recommendation_subject: Request to write a recommendation
referral_name: Referral Name
referral_email: Referral Email
request_letter: Request Letter
request: Request
recommendation: Recommendations
academic_type: Academic Type
salary_range: Salary Range
min_salary: Min Salary
max_salary: Max Salary
thousands: Thousands
month: Month
first_thing: This will be the first thing companies will see on your profile.
leave_blank: Leave blank if its your current job.
welcome: Welcome
@ -67,7 +92,7 @@ en:
finish: Finish
employee_portfolio: Employee Portfolio
current_company: Current Company
introduction: introduction
introduction: Introduction
intro_example: "Example: Professional developer with 6 years of experience with good knowledge of computer languages."
current_location: Current Location
recommendation_name_contact: Recommendation name and contact

View File

@ -2,6 +2,27 @@ zh_tw:
module_name:
recruitment: 招募
recruitment:
min_qualification: Min Qualification
referral_already_recommended: Sorry! You already have written a recommendation for this user.
name: Name
contact_email: Contact Email
recommendation_letter: Recommendation Letter
date: Date
thank_you_recommendation: Thank you for your recommendation.
user_not_found: Sorry! The user you are looking for is not available.
referral_not_authorized: Sorry! You are not authorized to write a recommendation.
recommendation_subject: Request to write a recommendation
referral_name: Referral Name
referral_email: Referral Email
request_letter: Request Letter
request: Request
recommendation: Recommendations
academic_type: Academic Type
salary_range: Salary Range
min_salary: Min Salary
max_salary: Max Salary
thousands: Thousands
month: Month
first_thing: This will be the first thing companies will see on your profile.
leave_blank: Leave blank if its your current job.
welcome: 歡迎

View File

@ -52,6 +52,11 @@ Rails.application.routes.draw do
post "/applyjob", to: "recruitments#applyjob"
get "/:id/job_applications", to: "recruitments#job_applications"
get "/:id/archive_application", to: "recruitments#archive_application"
get "/employee_recommendation", to: "recruitments#employee_recommendation"
post "/employee_recommendation", to: "recruitments#employee_recommendation"
get "/:id/write_recommendation", to: "recruitments#write_recommendation"
post "create_recommendation", to: "recruitments#create_recommendation"
delete "/:id/delete_employee_recommendation", to: "recruitments#delete_employee_recommendation"
end
end
end