add expiry date

This commit is contained in:
IT 2018-08-13 14:23:39 +08:00
parent 1f1db7331a
commit 563e42fdeb
4 changed files with 17 additions and 2 deletions

View File

@ -51,7 +51,8 @@ class RecruitmentJob
scope :jobs, ->{where(:post_type => "type1")} scope :jobs, ->{where(:post_type => "type1")}
scope :internships, ->{where(:post_type => "type2")} scope :internships, ->{where(:post_type => "type2")}
scope :exchanges, ->{where(:post_type => "type3")} 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 def get_category
RecruitmentCategory.find(self.category).job_category rescue "" RecruitmentCategory.find(self.category).job_category rescue ""

View File

@ -19,7 +19,7 @@
<% jobcount = job.get_application_count %> <% jobcount = job.get_application_count %>
<td><%= jobcount %></td> <td><%= jobcount %></td>
<td><%= job.get_post_type_label.html_safe %></td> <td><%= job.get_post_type_label.html_safe %></td>
<td><%= job.expiry_date.strftime("%Y/%m/%d %H:%M") %></td> <td><%= (!job.expiry_date.nil? ? job.expiry_date.strftime("%Y/%m/%d %H:%M") : "") %></td>
<td> <td>
<% if jobcount > 0 %> <% if jobcount > 0 %>
<a href="<%= applications_admin_recruitment_path(job.id) %>" class="btn btn-default"><%= t("recruitment.show_application") %></a> <a href="<%= applications_admin_recruitment_path(job.id) %>" class="btn btn-default"><%= t("recruitment.show_application") %></a>

View File

@ -102,6 +102,13 @@
<% end %> <% end %>
<hr> <hr>
<div class="form-group">
<%= f.label :expiry_date, t("recruitment.expiry_date"), :class => "col-sm-2 control-label" %>
<div class="col-sm-6">
<%= f.datetime_picker :expiry_date, :no_label => true, :new_record => @job.new_record? %>
</div>
</div>
<!-- exchange min credit score --> <!-- exchange min credit score -->
<div class="form-group"> <div class="form-group">
<%= f.label :min_credit_score, t("recruitment.min_credit_score"), :class => "col-sm-2 control-label" %> <%= f.label :min_credit_score, t("recruitment.min_credit_score"), :class => "col-sm-2 control-label" %>

View File

@ -59,6 +59,13 @@
<% end %> <% end %>
<hr> <hr>
<div class="form-group">
<%= f.label :expiry_date, t("recruitment.expiry_date"), :class => "col-sm-2 control-label" %>
<div class="col-sm-6">
<%= f.datetime_picker :expiry_date, :no_label => true, :new_record => @job.new_record? %>
</div>
</div>
<!-- internship partime --> <!-- internship partime -->
<div class="form-group"> <div class="form-group">