Implement changing of the status of the CFP
Allow a user to start and end a call for participation from the conference list.
This commit is contained in:
parent
574b6ec194
commit
2b64461ac9
|
@ -1,4 +1,6 @@
|
|||
$ ->
|
||||
$('.cfp-toggle').click ->
|
||||
$(this).addClass("disabled")
|
||||
Morris.Line
|
||||
element: 'submissions-chart'
|
||||
data: $('#submissions-chart').data('submissions')
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module Management
|
||||
class CallForParticipationsController < ManagementController
|
||||
before_action :assign_conference
|
||||
|
||||
def create
|
||||
@conference.call_for_participation.open!
|
||||
render :redraw
|
||||
end
|
||||
|
||||
def destroy
|
||||
@conference.call_for_participation.close!
|
||||
render :redraw
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_conference
|
||||
@conference = Conference.find params[:conference_id]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +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
|
||||
= 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
|
||||
= icon 'circle-o', class: 'fa-fw'
|
|
@ -0,0 +1,2 @@
|
|||
$('#cfp-status-<%= @conference.id %>').replaceWith('<%= j render partial: 'status', locals: {conference: @conference}%>');
|
||||
$('#cfp-status-<%= @conference.id %>').children('.cfp-toggle').click(function() {$(this).addClass("disabled");});
|
|
@ -3,12 +3,7 @@ tr
|
|||
td.hidden-xs.hidden-sm = l conference.start_date.to_date, format: :long
|
||||
td.hidden-xs.hidden-sm = l conference.end_date.to_date, format: :long
|
||||
td.action
|
||||
- if conference.call_for_papers_open?
|
||||
= link_to '#', method: :delete, class: 'btn btn-sm btn-success cfp-toggle', remote: true, onclick: '$(".cfp-toggle").addClass("disabled")'
|
||||
= icon 'dot-circle-o', '', class: 'fa-fw'
|
||||
- else
|
||||
= link_to '#', method: :post, class: 'btn btn-sm btn-warning cfp-toggle', remote: true, onclick: '$(".cfp-toggle").addClass("disabled")'
|
||||
= icon 'circle-o', class: 'fa-fw'
|
||||
= render partial: 'management/call_for_participations/status', locals: {conference: conference}
|
||||
|
||||
td = conference.events.count
|
||||
td.actions
|
||||
|
|
|
@ -8,6 +8,7 @@ Rails.application.routes.draw do
|
|||
resources :events
|
||||
resources :volunteers
|
||||
resources :sponsorship_offers
|
||||
resource :call_for_participation, only: [:create, :destroy]
|
||||
end
|
||||
resources :users
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Management::CallForParticipationsController, type: :controller do
|
||||
let(:user) { create :administrator }
|
||||
let(:conference) { create :conference }
|
||||
before { sign_in user }
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'opens the CFP of the specified conference' do
|
||||
expect do
|
||||
post 'create', conference_id: conference.id, format: :js
|
||||
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(false).to(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'closes the CFP of the specified conference' do
|
||||
conference.call_for_participation.open!
|
||||
|
||||
expect do
|
||||
delete 'destroy', conference_id: conference.id, format: :js
|
||||
end.to change { Conference.find(conference.id).call_for_participation.in_progress? }.from(true).to(false)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue