From 563e42fdeb58139c027617955d73d8353ecb6223 Mon Sep 17 00:00:00 2001 From: service Date: Mon, 13 Aug 2018 14:23:39 +0800 Subject: [PATCH] add expiry date --- app/models/recruitment_job.rb | 3 ++- app/views/admin/recruitments/_posting_index.html.erb | 2 +- app/views/recruitments/_exchange_form.html.erb | 7 +++++++ app/views/recruitments/_internship_form.html.erb | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/models/recruitment_job.rb b/app/models/recruitment_job.rb index 9c8dae7..35aa4fa 100644 --- a/app/models/recruitment_job.rb +++ b/app/models/recruitment_job.rb @@ -51,7 +51,8 @@ class RecruitmentJob scope :jobs, ->{where(:post_type => "type1")} scope :internships, ->{where(:post_type => "type2")} scope :exchanges, ->{where(:post_type => "type3")} - scope :not_expired, ->{any_of({:created_at.lt=>Time.now, :expiry_date.gt=>Time.now},{:created_at.lt=>Time.now, :expiry_date=>nil})} + #scope :not_expired, ->{any_of({:created_at.lt=>Time.now, :expiry_date.gt=>Time.now},{:created_at.lt=>Time.now, :expiry_date=>nil})} + scope :not_expired, ->{where(:created_at.lt=>Time.now, :expiry_date.gt=>Time.now)} def get_category RecruitmentCategory.find(self.category).job_category rescue "" diff --git a/app/views/admin/recruitments/_posting_index.html.erb b/app/views/admin/recruitments/_posting_index.html.erb index 8d0618d..5f4465e 100644 --- a/app/views/admin/recruitments/_posting_index.html.erb +++ b/app/views/admin/recruitments/_posting_index.html.erb @@ -19,7 +19,7 @@ <% jobcount = job.get_application_count %> <%= jobcount %> <%= job.get_post_type_label.html_safe %> - <%= job.expiry_date.strftime("%Y/%m/%d %H:%M") %> + <%= (!job.expiry_date.nil? ? job.expiry_date.strftime("%Y/%m/%d %H:%M") : "") %> <% if jobcount > 0 %> <%= t("recruitment.show_application") %> diff --git a/app/views/recruitments/_exchange_form.html.erb b/app/views/recruitments/_exchange_form.html.erb index b045a57..bd52b59 100644 --- a/app/views/recruitments/_exchange_form.html.erb +++ b/app/views/recruitments/_exchange_form.html.erb @@ -102,6 +102,13 @@ <% end %>
+
+ <%= f.label :expiry_date, t("recruitment.expiry_date"), :class => "col-sm-2 control-label" %> +
+ <%= f.datetime_picker :expiry_date, :no_label => true, :new_record => @job.new_record? %> +
+
+
<%= f.label :min_credit_score, t("recruitment.min_credit_score"), :class => "col-sm-2 control-label" %> diff --git a/app/views/recruitments/_internship_form.html.erb b/app/views/recruitments/_internship_form.html.erb index b6cad89..83929e8 100644 --- a/app/views/recruitments/_internship_form.html.erb +++ b/app/views/recruitments/_internship_form.html.erb @@ -59,6 +59,13 @@ <% end %>
+
+ <%= f.label :expiry_date, t("recruitment.expiry_date"), :class => "col-sm-2 control-label" %> +
+ <%= f.datetime_picker :expiry_date, :no_label => true, :new_record => @job.new_record? %> +
+
+