From a2ca1c9aeb0e307b181072a6259a08fe8ee57d90 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 15 Jan 2018 20:26:18 +0800 Subject: [PATCH] added internship and some changes --- .../stylesheets/recruitment/recruitment.scss | 6 + app/controllers/recruitments_controller.rb | 53 +++- app/models/recruitment_job.rb | 19 ++ .../recruitments/_dashboard_header.html.erb | 7 +- .../recruitments/_employee_dashboard.html.erb | 4 +- .../recruitments/_employee_form.html.erb | 7 +- .../recruitments/_employer_dashboard.html.erb | 11 +- .../recruitments/_internship_form.html.erb | 292 ++++++++++++++++++ app/views/recruitments/_job_form.html.erb | 1 + app/views/recruitments/addinternship.html.erb | 8 + app/views/recruitments/addjob.html.erb | 2 + app/views/recruitments/editjob.html.erb | 2 + app/views/recruitments/show.html.erb | 104 ++++--- config/locales/en.yml | 21 ++ config/locales/zh_tw.yml | 21 ++ config/routes.rb | 2 + 16 files changed, 482 insertions(+), 78 deletions(-) create mode 100644 app/views/recruitments/_internship_form.html.erb create mode 100644 app/views/recruitments/addinternship.html.erb diff --git a/app/assets/stylesheets/recruitment/recruitment.scss b/app/assets/stylesheets/recruitment/recruitment.scss index 5deccd6..19b2aa4 100644 --- a/app/assets/stylesheets/recruitment/recruitment.scss +++ b/app/assets/stylesheets/recruitment/recruitment.scss @@ -28,6 +28,12 @@ .logout { font-size: 16px; } + .header-title{ + text-align: center; + } + hr{ + border-top: 1px solid #5c5c5c; + } } ul.nav { diff --git a/app/controllers/recruitments_controller.rb b/app/controllers/recruitments_controller.rb index 4ceb57e..20d1178 100644 --- a/app/controllers/recruitments_controller.rb +++ b/app/controllers/recruitments_controller.rb @@ -8,7 +8,11 @@ class RecruitmentsController < PseudoSessionController def index params = OrbitHelper.params if params[:page_id] == "jobs" - load_jobs(params) + load_jobs(params, "type1") + elsif params[:page_id] == "internships" + load_jobs(params, "type2") + elsif params[:page_id] == "exchanges" + load_jobs(params, "type3") elsif params[:page_id] == "candidates" load_candidates(params) end @@ -65,17 +69,17 @@ class RecruitmentsController < PseudoSessionController } end - def load_jobs(params) + def load_jobs(params, type) jobs = [] if params[:type].present? && params[:type] == "aq" - rjobs = advanced_filter_jobs(params) + rjobs = advanced_filter_jobs(params,type) criteria = "- " elsif params[:q].present? - rjobs = filter_jobs(params) + rjobs = filter_jobs(params, type) criteria = "- " + params[:q] + " " else criteria = "" - rjobs = RecruitmentJob.not_filled + rjobs = RecruitmentJob.where(:post_type => type).not_filled end if !rjobs.nil? && !rjobs.is_a?(Array) rjobs = rjobs.desc(:created_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) @@ -105,6 +109,7 @@ class RecruitmentsController < PseudoSessionController "work_experience_years" => wey, "work_experience_months" => wem, "category" => rj.category, + "post-type" => rj.get_post_type_label, "skills" => rj.skills.collect{|skill| {"skill-tag" => skill}} } end @@ -119,7 +124,7 @@ class RecruitmentsController < PseudoSessionController def show params = OrbitHelper.params - if params[:page_id] == "jobs" + if params[:page_id] == "jobs" || params[:page_id] == "internships" || params[:page_id] == "exchanges" show_job(params) elsif params[:page_id] == "candidates" show_candidate(params) @@ -243,7 +248,7 @@ class RecruitmentsController < PseudoSessionController end end if !job.skills.empty? - skills = job.skills.collect{|skill| "#{skill}"} + skills = job.skills.collect{|skill| "#{skill}"} skills = skills.join(" ") else skills = t("recruitment.not_available") @@ -283,9 +288,21 @@ class RecruitmentsController < PseudoSessionController elsif job.max_salary < job.min_salary range = (job.min_salary * 1000).to_s + " ~ #{t('recruitment.salary.type1')} / Month" end + if job.internship_duration > 0 + duration = job.internship_duration.to_s + " #{t("recruitment.months")}" + end + if job.part_time? + parttime = "#{t("recruitment.internship_part_time")}" + end { "infos" => infos, "data" => { + "post-type" => job.get_post_type_label, + "part-time" => parttime, + "internship-duration-title" => t("recruitment.internship_duration"), + "internship-duration" => duration, + "perks-title" => t("recruitment.perks_title"), + "perks" => (job.perks.nil? || job.perks != "" ? t("recruitment.perks.#{job.perks}") : t("recruitment.not_available")), "job-title" => job.job_title, "job-category" => job.get_category, "avatar" => profile.get_avatar, @@ -559,15 +576,23 @@ class RecruitmentsController < PseudoSessionController redirect_to mydashboard_path end + + # ------ ------ internship ------ ------- # + + def addinternship + @job = RecruitmentJob.new + @academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]} + end + private - def filter_jobs(params) + def filter_jobs(params, type) rjobs = [] keywords = params[:q].split(",").collect{|s| /#{s.strip}/i} companies = EmployerProfile.where(:company_name.in => keywords).pluck(:id) - skills = RecruitmentJob.where(:skills.in => keywords) - designations = RecruitmentJob.where(:job_title.in => keywords) + skills = RecruitmentJob.where(:post_type => type).where(:skills.in => keywords) + designations = RecruitmentJob.where(:post_type => type).where(:job_title.in => keywords) query = [] if companies.count > 0 query << {:employer_profile_id.in => companies} @@ -579,14 +604,14 @@ class RecruitmentsController < PseudoSessionController query << {:job_title.in => keywords} end if !query.empty? - rjobs = RecruitmentJob.any_of(query).not_filled + rjobs = RecruitmentJob.where(:post_type => type).any_of(query).not_filled end rjobs end - def advanced_filter_jobs(params) + def advanced_filter_jobs(params, type) if params[:q].present? - rjobs = filter_jobs(params) + rjobs = filter_jobs(params, type) else rjobs = [] end @@ -614,7 +639,7 @@ class RecruitmentsController < PseudoSessionController if !rjobs.empty? rjobs = rjobs.where(query.reduce({}, :merge)) else - rjobs = RecruitmentJob.where(query.reduce({}, :merge)) + rjobs = RecruitmentJob.where(:post_type => type).where(query.reduce({}, :merge)) end end rjobs diff --git a/app/models/recruitment_job.rb b/app/models/recruitment_job.rb index 6b68424..d685c83 100644 --- a/app/models/recruitment_job.rb +++ b/app/models/recruitment_job.rb @@ -28,6 +28,12 @@ class RecruitmentJob field :min_salary, type: Integer, :default => 0 field :max_salary, type: Integer, :default => 0 + # internship + + field :part_time, type: Boolean, :default => false + field :internship_duration, type: Integer, :default => 0 + field :perks #type1 => certificate, type2 => placement offer, type3 => informal dress code + field :filled, type: Boolean, :default => false @@ -35,6 +41,8 @@ class RecruitmentJob belongs_to :employer_profile scope :not_filled, ->{where(:filled => false)} + scope :jobs, ->{where(:post_type => "type1")} + scope :internships, ->{where(:post_type => "type2")} def get_category RecruitmentCategory.find(self.category).job_category rescue "" @@ -44,4 +52,15 @@ class RecruitmentJob EmployeeJobApplication.where(:job => self.id.to_s).not_archived.count end + def get_post_type_label + case self.post_type + when "type1" + "#{I18n.t("recruitment.post_t.type1")}" + when "type2" + "#{I18n.t("recruitment.post_t.type2")}" + when "type3" + "#{I18n.t("recruitment.post_t.type3")}" + end + end + end \ No newline at end of file diff --git a/app/views/recruitments/_dashboard_header.html.erb b/app/views/recruitments/_dashboard_header.html.erb index ae07605..c7fbbd3 100644 --- a/app/views/recruitments/_dashboard_header.html.erb +++ b/app/views/recruitments/_dashboard_header.html.erb @@ -4,7 +4,7 @@ <% if params[:action] == "recruitment_dashboard" && @profile.is_employer? %> -
- <%= t("recruitment.add_job") %> + <% end %> \ No newline at end of file diff --git a/app/views/recruitments/_employee_dashboard.html.erb b/app/views/recruitments/_employee_dashboard.html.erb index bf6c373..6899955 100644 --- a/app/views/recruitments/_employee_dashboard.html.erb +++ b/app/views/recruitments/_employee_dashboard.html.erb @@ -1,7 +1,8 @@ - + + @@ -13,6 +14,7 @@ <% @applications.each do |app| %> <% job = app.get_job %> + diff --git a/app/views/recruitments/_employee_form.html.erb b/app/views/recruitments/_employee_form.html.erb index ef7048e..7a3cb05 100644 --- a/app/views/recruitments/_employee_form.html.erb +++ b/app/views/recruitments/_employee_form.html.erb @@ -10,12 +10,7 @@ <%= javascript_include_tag "lib/file-type" %> <%# end %> - - - - - + <% elsif data["type"] == "internships" %> + <%= render_view("internships") %> <% elsif data["type"] == "candidates" %> <%= render_view("candidate_show") %> <% end %> + <% case data["type"] + when "jobs", "internships" %> + + + + + + <% end %> <% else %>
Please login to view this page. ">Login
<%= t("recruitment.job_title") %><%= t("recruitment.post_type") %><%= t("recruitment.title") %> <%= t("recruitment.company_name") %> <%= t("recruitment.applied_date") %>
<%= job.get_post_type_label.html_safe %> " target="_blank"><%= job.job_title %> <%= job.employer_profile.company_name %> <%= app.created_at.strftime("%d %B %Y") %>