Conference controller cleanup and fixes
This commit is contained in:
parent
c2c108ca07
commit
965529981e
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
if conference.present?
|
||||
session[:current_conference_id] = conference.id
|
||||
else
|
||||
session.delete(:current_conference_id)
|
||||
end
|
||||
end
|
||||
|
||||
def authorize_user!
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
$('#conferences tbody').html('<%= j render @conferences %>');
|
Loading…
Reference in New Issue