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