From f87cd94cb5b2369b463b642fe965a501aae0b69b Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Wed, 4 Jun 2014 23:55:02 +0530 Subject: [PATCH 1/3] Added method registration_dates_given? --- app/models/conference.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index 7f13cdd2..c8019aca 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -102,11 +102,25 @@ class Conference < ActiveRecord::Base # * +true+ -> If today is in the registration period. def registration_open? today = Date.current - if self.registration_start_date.blank? || self.registration_end_date.blank? + if registration_dates_given? + (registration_start_date..registration_end_date).cover?(today) + else false end + end - (registration_start_date..registration_end_date).cover?(today) + ## + # Checks if the registration dates for the conference are provided + # + # ====Returns + # * +false+ -> If the conference registration dates are not set + # * +true+ -> If conference registration dates are set + def registration_dates_given? + if self.registration_start_date.blank? || self.registration_end_date.blank? + false + else + true + end end ## From fd20e67c7689864108971b66e89ce49dceb9435f Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Thu, 5 Jun 2014 01:12:43 +0530 Subject: [PATCH 2/3] Modified rendering for registration dates in splash --- app/models/conference.rb | 2 +- app/views/conference/_registration.html.haml | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index c8019aca..b49a901e 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -116,7 +116,7 @@ class Conference < ActiveRecord::Base # * +false+ -> If the conference registration dates are not set # * +true+ -> If conference registration dates are set def registration_dates_given? - if self.registration_start_date.blank? || self.registration_end_date.blank? + if registration_start_date.blank? || registration_end_date.blank? false else true diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index 5f52422b..0b63646b 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -7,7 +7,11 @@ - if !@conference.registration_description.blank? %p = @conference.registration_description - %h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } + - if @conference.registration_dates_given? + -if @conference.registration_end_date >= Date.today + %h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } + -else + %h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } - if @conference.registration_open? = link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank' - if @conference.use_supporter_levels? From 035acada247cd579777c46ef0aaabcab9abb932a Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Thu, 5 Jun 2014 11:59:19 +0530 Subject: [PATCH 3/3] Fix volunteers spec, failing test due zero in days --- spec/features/volunteers_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/volunteers_spec.rb b/spec/features/volunteers_spec.rb index d8c39c60..df696adf 100644 --- a/spec/features/volunteers_spec.rb +++ b/spec/features/volunteers_spec.rb @@ -71,7 +71,7 @@ feature Conference do set("#{Date.today.strftime('%B')}") page. find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). - set("#{Date.today.strftime('%d')}") + set("#{Date.today.strftime('%-d')}") page. find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). set('Example Person')