From 1de8f979cd8230fafe017f0d30695d6b03f0049f Mon Sep 17 00:00:00 2001 From: raluka Date: Fri, 21 Aug 2015 19:15:02 +0200 Subject: [PATCH] Issue #649: Wrong days remaining label when submitting a new proposal --- app/models/call_for_paper.rb | 5 +++++ app/views/admin/call_for_papers/show.html.haml | 3 +-- app/views/conference/_call_for_paper.html.haml | 15 ++++++++------- .../proposal/_encouragement_text.html.haml | 18 +++++++++--------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/models/call_for_paper.rb b/app/models/call_for_paper.rb index e72b0f79..0d4f6ab1 100644 --- a/app/models/call_for_paper.rb +++ b/app/models/call_for_paper.rb @@ -63,6 +63,11 @@ class CallForPaper < ActiveRecord::Base && !self.conference.email_settings.call_for_papers_dates_updates_template.blank? end + def remaining_days(date = Date.today) + result = (self.end_date - date).to_i + result > 0 ? result : 0 + end + private def before_end_of_conference diff --git a/app/views/admin/call_for_papers/show.html.haml b/app/views/admin/call_for_papers/show.html.haml index f05315ed..a2aacfb2 100644 --- a/app/views/admin/call_for_papers/show.html.haml +++ b/app/views/admin/call_for_papers/show.html.haml @@ -19,8 +19,7 @@ %dt Days Left: %dd - - days = (@call_for_paper.end_date - Date.today).to_i - = pluralize(days, 'days') + = pluralize(@call_for_paper.remaining_days, 'day') %dt Event types: %dd diff --git a/app/views/conference/_call_for_paper.html.haml b/app/views/conference/_call_for_paper.html.haml index 1526751c..32e2efe2 100644 --- a/app/views/conference/_call_for_paper.html.haml +++ b/app/views/conference/_call_for_paper.html.haml @@ -25,14 +25,15 @@ and closes %em = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') - That means you have only - - days = (@conference.call_for_paper.end_date - Date.today).to_i - %b - = pluralize(days, 'days') + - if @conference.cfp_open? + That means you have only + %b= pluralize(@conference.call_for_paper.remaining_days, 'day') left! - Remember - = @conference.short_title - will only be as good as the sessions you present. Submit early, submit often! + Remember + = @conference.short_title + will only be as good as the sessions you present. Submit early, submit often! + - else + The submission period is closed. .row .col-md-12.text-center %p.cta-button diff --git a/app/views/proposal/_encouragement_text.html.haml b/app/views/proposal/_encouragement_text.html.haml index 44b51d95..52fed803 100644 --- a/app/views/proposal/_encouragement_text.html.haml +++ b/app/views/proposal/_encouragement_text.html.haml @@ -6,18 +6,18 @@ Proposals should fit in one of the = "#{pluralize(@conference.tracks.count, 'track')}:" = "#{tracks(@conference)}." - - if @conference.call_for_paper + - if @conference.cfp_open? The submission period has begun %em = @conference.call_for_paper.start_date.strftime('%A, %B %-d. %Y') and closes %em = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') - That means you have only - - days = (@conference.call_for_paper.end_date - Date.today).to_i - %b - = pluralize(days, 'days') - left! - Remember - = @conference.title - will only be as good as the content you present. Submit early, submit often! + That means you have + %b= pluralize(@conference.call_for_paper.remaining_days, 'day') + left! + Remember + = @conference.title + will only be as good as the content you present. Submit early, submit often! + -else + The submission period is closed now.