From 4d9f34c3cf1f7a4962208400114ee7eed0965b34 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 09:29:50 +0530 Subject: [PATCH 1/4] conditional rendering for registration period --- app/views/conference/_registration.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index 5f52422b..23973993 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -7,7 +7,8 @@ - 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_open? + %h4 Registration period #{ 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 0d3b0cfe2c1bbdd786e957f637a5aa07aaeca898 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 13:06:10 +0530 Subject: [PATCH 2/4] Registration alerts modified for splash --- app/models/conference.rb | 14 +++++++++++--- app/views/conference/_registration.html.haml | 7 +++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index b1ee2b32..5f888ea6 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -100,13 +100,21 @@ class Conference < ActiveRecord::Base # * +false+ -> If the conference dates are not set or today isn't in the # registration period. # * +true+ -> If today is in the registration period. - def registration_open? - today = Date.current + def registration_dates_given? if self.registration_start_date.blank? || self.registration_end_date.blank? false + else + true end + end - (registration_start_date..registration_end_date).cover?(today) + def registration_open? + today = Date.current + if registration_dates_given? + (registration_start_date..registration_end_date).cover?(today) + else + false + end end ## diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index 23973993..b0b75011 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -7,8 +7,11 @@ - if !@conference.registration_description.blank? %p = @conference.registration_description - - if @conference.registration_open? - %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 506b616341134ae38382c15daae0b11a33fa296c Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 13:11:01 +0530 Subject: [PATCH 3/4] changed greater than to greater than equal --- app/views/conference/_registration.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index b0b75011..0b63646b 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -8,7 +8,7 @@ %p = @conference.registration_description - if @conference.registration_dates_given? - -if @conference.registration_end_date > Date.today + -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) } From fae5981dc4939a630afc3378b8d28fcb9db8818e Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 23:52:56 +0530 Subject: [PATCH 4/4] Added documentation for the new method added --- app/models/conference.rb | 21 ++++++++++++-------- app/views/conference/show.html.haml | 2 +- spec/views/conference/show.html.haml_spec.rb | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index 5f888ea6..a5d8db44 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -100,14 +100,6 @@ class Conference < ActiveRecord::Base # * +false+ -> If the conference dates are not set or today isn't in the # registration period. # * +true+ -> If today is in the registration period. - def registration_dates_given? - if self.registration_start_date.blank? || self.registration_end_date.blank? - false - else - true - end - end - def registration_open? today = Date.current if registration_dates_given? @@ -116,6 +108,19 @@ class Conference < ActiveRecord::Base false end end + ## + # 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 ## # Checks if the call for papers for the conference is currently open diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index cbadd6d3..64a866a0 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -1,9 +1,9 @@ = content_for :brand do = link_to @conference.title, conference_url(@conference.short_title), class: 'navbar-brand' + %div#program = render 'program' %div#registration = render 'registration' %div#callforpapers = render 'call_for_papers' - diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 8e32e586..1aeb93e0 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -11,7 +11,7 @@ describe 'conference/show.html.haml' do end it 'renders program partial' do - expect(render).to include("#{@conference.description}") + expect(rendered).to include("#{@conference.description}") expect(view).to render_template(partial: 'conference/_program') end @@ -21,6 +21,6 @@ describe 'conference/show.html.haml' do end it 'renders call_for_papers partial' do - expect(render).to include("#{@conference.call_for_papers.description}") + expect(rendered).to include("#{@conference.call_for_papers.description}") end end