From 33247cb690519880fe8456843377169c8a561714 Mon Sep 17 00:00:00 2001 From: Carlos Coelho Date: Mon, 14 Mar 2016 14:09:15 -0300 Subject: [PATCH 1/4] Get withdrawn events list Signed-off-by: Carlos Coelho --- app/controllers/admin/conference_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 1c1045e9..03079a76 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -160,6 +160,9 @@ module Admin # get campaigns @campaigns = @conference.get_campaigns + # get withdrawn events + @withdrawn_events = @conference.program.events.where(state: :withdrawn) + respond_to do |format| format.html format.json { render json: @conference.to_json } From 72c71fc51042d3fe032ae17cc63025b9c33c9e5c Mon Sep 17 00:00:00 2001 From: Carlos Coelho Date: Mon, 14 Mar 2016 16:53:05 -0300 Subject: [PATCH 2/4] Added inflection to pluralize was Signed-off-by: Carlos Coelho --- config/initializers/inflections.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be2..41a2d06d 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -13,3 +13,6 @@ # ActiveSupport::Inflector.inflections do |inflect| # inflect.acronym 'RESTful' # end +ActiveSupport::Inflector.inflections do |inflect| + inflect.irregular "was", "were" +end From e268acec232d3bafc6d0f2d810646bf6e02d7335 Mon Sep 17 00:00:00 2001 From: Carlos Coelho Date: Mon, 14 Mar 2016 16:55:22 -0300 Subject: [PATCH 3/4] Added alert to withdrawn events Signed-off-by: Carlos Coelho --- app/views/admin/conference/show.html.haml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/admin/conference/show.html.haml b/app/views/admin/conference/show.html.haml index 7ce1c408..5e25a7af 100644 --- a/app/views/admin/conference/show.html.haml +++ b/app/views/admin/conference/show.html.haml @@ -1,3 +1,11 @@ +- if !@withdrawn_events.empty? + .alert.alert-warning.alert-dismissible{role: 'alert'} + %button.close{data: {dismiss: 'alert'}, aria: {label: 'Close'}, type: 'button'} + %span{aria: {hidden: 'true'}} + × + Sadly #{pluralize(@withdrawn_events.count, 'event')} #{'was'.pluralize(@withdrawn_events.count)} withdrawn. + = link_to 'Click here', admin_conference_program_events_path(@conference.short_title) + %h1 %span.fa.fa-tachometer Dashboard for #{@conference.title} From 6beb9f68ab4ea17c6292f80802f98eed784c7474 Mon Sep 17 00:00:00 2001 From: Carlos Coelho Date: Mon, 14 Mar 2016 17:47:47 -0300 Subject: [PATCH 4/4] Moved withdrawn_event check to helper Signed-off-by: Carlos Coelho --- app/controllers/admin/conference_controller.rb | 3 --- app/helpers/admin/conference_helper.rb | 11 +++++++++++ app/views/admin/conference/show.html.haml | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 app/helpers/admin/conference_helper.rb diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 03079a76..1c1045e9 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -160,9 +160,6 @@ module Admin # get campaigns @campaigns = @conference.get_campaigns - # get withdrawn events - @withdrawn_events = @conference.program.events.where(state: :withdrawn) - respond_to do |format| format.html format.json { render json: @conference.to_json } diff --git a/app/helpers/admin/conference_helper.rb b/app/helpers/admin/conference_helper.rb new file mode 100644 index 00000000..5130abac --- /dev/null +++ b/app/helpers/admin/conference_helper.rb @@ -0,0 +1,11 @@ +module Admin + module ConferenceHelper + def withdrawn_events?(conference) + conference.program.events.where(state: :withdrawn).empty? + end + + def withdrawn_events_count(conference) + conference.program.events.where(state: :withdrawn).count + end + end +end diff --git a/app/views/admin/conference/show.html.haml b/app/views/admin/conference/show.html.haml index 5e25a7af..01c17416 100644 --- a/app/views/admin/conference/show.html.haml +++ b/app/views/admin/conference/show.html.haml @@ -1,9 +1,9 @@ -- if !@withdrawn_events.empty? +- if !withdrawn_events?(@conference) .alert.alert-warning.alert-dismissible{role: 'alert'} %button.close{data: {dismiss: 'alert'}, aria: {label: 'Close'}, type: 'button'} %span{aria: {hidden: 'true'}} × - Sadly #{pluralize(@withdrawn_events.count, 'event')} #{'was'.pluralize(@withdrawn_events.count)} withdrawn. + Sadly #{pluralize(withdrawn_events_count(@conference), 'event')} #{'was'.pluralize(withdrawn_events_count(@conference))} withdrawn. = link_to 'Click here', admin_conference_program_events_path(@conference.short_title) %h1