Conference controller cleanup and fixes
This commit is contained in:
parent
c2c108ca07
commit
965529981e
|
@ -1,8 +1,5 @@
|
||||||
module Management
|
module Management
|
||||||
class ConferencesController < ManagementController
|
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
|
def new
|
||||||
@conference = Conference.new
|
@conference = Conference.new
|
||||||
@conference.tracks.build(name: 'Track 1')
|
@conference.tracks.build(name: 'Track 1')
|
||||||
|
@ -21,48 +18,36 @@ module Management
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@conference = find_conference
|
||||||
@conference.update(conference_params)
|
@conference.update(conference_params)
|
||||||
@conference.save
|
@conference.save
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@conference = find_conference
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@conferences = Conference.all.order(start_date: :desc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@conference = find_conference
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@conference = find_conference
|
||||||
@conference.destroy
|
@conference.destroy
|
||||||
|
set_current_conference(nil)
|
||||||
|
|
||||||
render 'reload_table'
|
redirect_to management_root_path
|
||||||
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'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assign_conference
|
def find_conference
|
||||||
@conference = Conference.find params[:id]
|
Conference.find(params[:id])
|
||||||
end
|
|
||||||
|
|
||||||
def assign_conferences
|
|
||||||
@conferences = Conference.all.order(start_date: :desc)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def conference_params
|
def conference_params
|
||||||
|
|
|
@ -7,17 +7,21 @@ module Management
|
||||||
private
|
private
|
||||||
|
|
||||||
def current_conference?
|
def current_conference?
|
||||||
session[:current_conference_id] and current_conference.present?
|
current_conference.present?
|
||||||
end
|
end
|
||||||
helper_method :current_conference?
|
helper_method :current_conference?
|
||||||
|
|
||||||
def 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
|
end
|
||||||
helper_method :current_conference
|
helper_method :current_conference
|
||||||
|
|
||||||
def set_current_conference(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
|
end
|
||||||
|
|
||||||
def authorize_user!
|
def authorize_user!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
div id="cfp-status-#{conference.id}"
|
div id="cfp-status-#{conference.id}"
|
||||||
- if conference.call_for_participation.in_progress?
|
- 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'
|
= icon 'dot-circle-o', '', class: 'fa-fw'
|
||||||
- else
|
- 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'
|
= icon 'circle-o', class: 'fa-fw'
|
||||||
|
|
|
@ -12,5 +12,5 @@ tr
|
||||||
= icon :eye
|
= icon :eye
|
||||||
= link_to edit_management_conference_path(conference), title: t('actions.edit.button', model: Conference.model_name.human), class: 'btn btn-primary'
|
= link_to edit_management_conference_path(conference), title: t('actions.edit.button', model: Conference.model_name.human), class: 'btn btn-primary'
|
||||||
= icon :edit
|
= 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
|
= icon :trash
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
$('#conferences tbody').html('<%= j render @conferences %>');
|
|
Loading…
Reference in New Issue