From 2aa5d0193195225bdb212fa1aadeb0bdd50d2aa1 Mon Sep 17 00:00:00 2001 From: Jessica Lie Date: Sat, 17 Oct 2015 12:34:21 -0700 Subject: [PATCH 1/4] change UI dates --- app/views/jobs/_form.html.haml | 4 ++-- app/views/jobs/show.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/jobs/_form.html.haml b/app/views/jobs/_form.html.haml index 392fe82a..894ab912 100644 --- a/app/views/jobs/_form.html.haml +++ b/app/views/jobs/_form.html.haml @@ -42,11 +42,11 @@ %dd = text_field :proglang, :name, :value => @job.proglang_list_of_job(true), :class => 'form-control', :placeholder => "(e.g. Python, machine shop)" %dt - = f.label :earliest_start_date, 'Earliest start date *' + = f.label :earliest_start_date, 'Start date *' %dd = f.text_field :earliest_start_date, :class => 'datepicker form-control', value: @job.earliest_start_date.present? ? @job.earliest_start_date.strftime("%Y-%m-%d") : nil %dt - = f.label :latest_start_date, 'Latest start date *' + = f.label :latest_start_date, 'Apply by *' %dd = f.text_field :latest_start_date, :class => 'datepicker form-control', value: @job.latest_start_date.present? ? @job.latest_start_date.strftime("%Y-%m-%d") : nil %dt diff --git a/app/views/jobs/show.html.haml b/app/views/jobs/show.html.haml index 3d00debc..f63b6712 100644 --- a/app/views/jobs/show.html.haml +++ b/app/views/jobs/show.html.haml @@ -73,10 +73,10 @@ = h @job.proglang_list_of_job(true) - else (none) - %dt Earliest start date + %dt Start date %dd = @job.earliest_start_date.strftime("%b %e, %Y") - %dt Latest start date + %dt Apply by %dd = @job.latest_start_date.strftime("%b %e, %Y") %dt Position end date From 8e8864929614abfeff90bec067c279ae95d4a2ce Mon Sep 17 00:00:00 2001 From: Jessica Lie Date: Wed, 21 Oct 2015 16:58:00 -0700 Subject: [PATCH 2/4] cron and closing job --- app/controllers/jobs_controller.rb | 9 ++++++++- app/models/job.rb | 5 +++-- lib/tasks/scheduler.rake | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 lib/tasks/scheduler.rake diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb index 522b7eed..0465e817 100644 --- a/app/controllers/jobs_controller.rb +++ b/app/controllers/jobs_controller.rb @@ -281,8 +281,15 @@ def unwatch flash[:notice] = 'Job is now unwatched. You can find a list of your watched jobs on the dashboard.' redirect_to :back end + + def close_jobs + jobs = Job.where('latest_start_date < ?', Time.now) - + jobs.each do |job| + job.update_attribute(:status, 1) + job.save(validate: false) + end + end protected diff --git a/app/models/job.rb b/app/models/job.rb index e43fc9a1..186ccfd6 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -434,13 +434,14 @@ def resend_email(send_email = false) protected + #delete this? def earliest_start_date_must_be_before_latest - errors[:earliest_start_date] << "cannot be later than the latest start date" if + errors[:start_date] << "cannot be later than the latest start date" if latest_start_date.present? && earliest_start_date > latest_start_date end def latest_start_date_must_be_before_end_date - errors.add(:latest_start_date, "cannot be later than the end date") if + errors.add(:apply_by_date, "cannot be later than the end date") if latest_start_date.present? && !open_ended_end_date && latest_start_date > end_date end diff --git a/lib/tasks/scheduler.rake b/lib/tasks/scheduler.rake new file mode 100644 index 00000000..3bfb6045 --- /dev/null +++ b/lib/tasks/scheduler.rake @@ -0,0 +1,4 @@ +desc "This task is called by the Heroku scheduler add-on" +task :close_jobs => :environment do + Jobs.close_jobs +end From 8d639e926eee0ac65b98fd4c6becbcb2200b267b Mon Sep 17 00:00:00 2001 From: Jessica Lie Date: Wed, 28 Oct 2015 16:04:02 -0700 Subject: [PATCH 3/4] move to rb --- app/models/job.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/job.rb b/app/models/job.rb index 014227ae..2518f297 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -341,6 +341,15 @@ def self.human_attribute_name(attr, options = {}) end return super end + + def self.close_jobs + jobs = Job.where('latest_start_date < ?', Time.now) + + jobs.each do |job| + job.update_attribute(:status, 1) + job.save(validate: false) + end + end # Returns a string containing the category names taken by this Job # e.g. "robotics,signal processing" @@ -434,6 +443,8 @@ def resend_email(send_email = false) end end + + protected #delete this? From bb26ca7d9190be2cc51ddae5ba5d40294a8183c5 Mon Sep 17 00:00:00 2001 From: Jessica Lie Date: Wed, 4 Nov 2015 17:03:10 -0800 Subject: [PATCH 4/4] change apply by to applcation deadline --- app/views/jobs/_form.html.haml | 2 +- app/views/jobs/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/jobs/_form.html.haml b/app/views/jobs/_form.html.haml index 8246a767..3ddbb34d 100644 --- a/app/views/jobs/_form.html.haml +++ b/app/views/jobs/_form.html.haml @@ -47,7 +47,7 @@ %dd = f.text_field :earliest_start_date, :class => 'datepicker form-control', value: @job.earliest_start_date.present? ? @job.earliest_start_date.strftime("%Y-%m-%d") : nil %dt - = f.label :latest_start_date, 'Apply by *' + = f.label :latest_start_date, 'Application Deadline*' %dd = f.text_field :latest_start_date, :class => 'datepicker form-control', value: @job.latest_start_date.present? ? @job.latest_start_date.strftime("%Y-%m-%d") : nil %dt diff --git a/app/views/jobs/show.html.haml b/app/views/jobs/show.html.haml index cb965c19..3c1ea9dc 100644 --- a/app/views/jobs/show.html.haml +++ b/app/views/jobs/show.html.haml @@ -79,7 +79,7 @@ %dt Start date %dd = @job.earliest_start_date.strftime("%b %e, %Y") - %dt Apply by + %dt Application Deadline %dd = @job.latest_start_date.strftime("%b %e, %Y") %dt Position end date