diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index 1a68d9d..d7a198a 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -1,8 +1,5 @@ module Management class ConferencesController < ManagementController - before_action :assign_conference, only: [:edit, :update, :show, :destroy, :open_call_for_papers, :close_call_for_papers] - before_action :assign_conferences, only: [:index, :destroy, :open_call_for_papers, :close_call_for_papers] - def new @conference = Conference.new @conference.tracks.build(name: 'Track 1') @@ -21,48 +18,36 @@ module Management end def update + @conference = find_conference @conference.update(conference_params) @conference.save render :edit end def edit + @conference = find_conference end def index + @conferences = Conference.all.order(start_date: :desc) end def show + @conference = find_conference end def destroy + @conference = find_conference @conference.destroy + set_current_conference(nil) - render 'reload_table' - end - - def open_call_for_papers - @conference.call_for_papers_open = true - @conference.save - - render 'reload_table' - end - - def close_call_for_papers - @conference.call_for_papers_open = false - @conference.save - - render 'reload_table' + redirect_to management_root_path end private - def assign_conference - @conference = Conference.find params[:id] - end - - def assign_conferences - @conferences = Conference.all.order(start_date: :desc) + def find_conference + Conference.find(params[:id]) end def conference_params diff --git a/app/controllers/management/management_controller.rb b/app/controllers/management/management_controller.rb index 2c66ed5..80f6bfa 100644 --- a/app/controllers/management/management_controller.rb +++ b/app/controllers/management/management_controller.rb @@ -7,17 +7,21 @@ module Management private def current_conference? - session[:current_conference_id] and current_conference.present? + current_conference.present? end helper_method :current_conference? def current_conference - @current_conference ||= Conference.find(session[:current_conference_id]) + @current_conference ||= (session[:current_conference_id] and Conference.find_by(id: session[:current_conference_id])) end helper_method :current_conference def set_current_conference(conference) - session[:current_conference_id] = conference.id + if conference.present? + session[:current_conference_id] = conference.id + else + session.delete(:current_conference_id) + end end def authorize_user! diff --git a/app/views/management/call_for_participations/_status.html.slim b/app/views/management/call_for_participations/_status.html.slim index 17a109b..81263ef 100644 --- a/app/views/management/call_for_participations/_status.html.slim +++ b/app/views/management/call_for_participations/_status.html.slim @@ -1,7 +1,7 @@ div id="cfp-status-#{conference.id}" - if conference.call_for_participation.in_progress? - = link_to management_conference_call_for_participation_path(conference), method: :delete, class: 'btn btn-sm btn-success cfp-toggle', remote: true + = link_to management_call_for_participation_path(conference), method: :delete, class: 'btn btn-sm btn-success cfp-toggle', remote: true = icon 'dot-circle-o', '', class: 'fa-fw' - else - = link_to management_conference_call_for_participation_path(conference), method: :post, class: 'btn btn-sm btn-warning cfp-toggle', remote: true + = link_to management_call_for_participation_path(conference), method: :post, class: 'btn btn-sm btn-warning cfp-toggle', remote: true = icon 'circle-o', class: 'fa-fw' diff --git a/app/views/management/conferences/_conference.html.slim b/app/views/management/conferences/_conference.html.slim index df99593..70974b8 100644 --- a/app/views/management/conferences/_conference.html.slim +++ b/app/views/management/conferences/_conference.html.slim @@ -12,5 +12,5 @@ tr = icon :eye = link_to edit_management_conference_path(conference), title: t('actions.edit.button', model: Conference.model_name.human), class: 'btn btn-primary' = icon :edit - = link_to management_conference_path(conference), title: t('actions.destroy.button', model: Conference.model_name.human), class: ['btn', 'btn-danger', conference.events.any? ? 'disabled' : nil], remote: true, method: :delete, data: {confirm: t('actions.are_you_sure')} + = link_to management_conference_path(conference), title: t('actions.destroy.button', model: Conference.model_name.human), class: ['btn', 'btn-danger', conference.events.any? ? 'disabled' : nil], method: :delete, data: {confirm: t('actions.are_you_sure')} = icon :trash diff --git a/app/views/management/conferences/reload_table.js.erb b/app/views/management/conferences/reload_table.js.erb deleted file mode 100644 index 64ae1b6..0000000 --- a/app/views/management/conferences/reload_table.js.erb +++ /dev/null @@ -1 +0,0 @@ -$('#conferences tbody').html('<%= j render @conferences %>');