@ -26,7 +26,8 @@ class WorkshopsController < ApplicationController
def create_workshop
def create_workshop
set_conference
set_conference
set_conference_registration!
ensure_registration_is_complete!
@workshop = Workshop . new
@workshop = Workshop . new
@languages = [ I18n . locale . to_sym ]
@languages = [ I18n . locale . to_sym ]
@needs = [ ]
@needs = [ ]
@ -47,7 +48,7 @@ class WorkshopsController < ApplicationController
def edit_workshop
def edit_workshop
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless @workshop . present?
return do_404 unless @workshop . present?
@ -82,7 +83,7 @@ class WorkshopsController < ApplicationController
def delete_workshop
def delete_workshop
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless @workshop . present?
return do_404 unless @workshop . present?
@ -95,9 +96,9 @@ class WorkshopsController < ApplicationController
@workshop . destroy
@workshop . destroy
end
end
return redirect_to register_step _path( @this_conference . slug , 'workshops' )
return redirect_to workshops _path( @this_conference . slug )
end
end
return redirect_to view_workshop_url ( @this_conference . slug , @workshop . id )
return redirect_to view_workshop_path ( @this_conference . slug , @workshop . id )
end
end
@register_template = :workshops
@register_template = :workshops
@ -106,13 +107,13 @@ class WorkshopsController < ApplicationController
def save_workshop
def save_workshop
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
if params [ :button ] . to_sym != :save
if params [ :button ] . to_sym != :save
if params [ :workshop_id ] . present?
if params [ :workshop_id ] . present?
return redirect_to view_workshop_url ( @this_conference . slug , params [ :workshop_id ] )
return redirect_to view_workshop_path ( @this_conference . slug , params [ :workshop_id ] )
end
end
return redirect_to register_step _path( @this_conference . slug , 'workshops' )
return redirect_to workshops _path( @this_conference . slug )
end
end
if params [ :workshop_id ] . present?
if params [ :workshop_id ] . present?
@ -120,8 +121,8 @@ class WorkshopsController < ApplicationController
return do_404 unless workshop . present?
return do_404 unless workshop . present?
can_edit = workshop . can_edit? ( current_user )
can_edit = workshop . can_edit? ( current_user )
else
else
workshop = Workshop . new ( :conference_id = > @this_conference . id )
workshop = Workshop . new ( conference_id : @this_conference . id )
workshop . workshop_facilitators = [ WorkshopFacilitator . new ( :user_id = > current_user . id , :role = > :creator ) ]
workshop . workshop_facilitators = [ WorkshopFacilitator . new ( user_id : current_user . id , role : :creator ) ]
can_edit = true
can_edit = true
end
end
@ -157,27 +158,27 @@ class WorkshopsController < ApplicationController
workshop . save
workshop . save
# Rouge nil facilitators have been know to be created, just destroy them here now
# Rouge nil facilitators have been know to be created, just destroy them here now
WorkshopFacilitator . where ( :user_id = > nil ) . destroy_all
WorkshopFacilitator . where ( user_id : nil ) . destroy_all
else
else
return do_403
return do_403
end
end
redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
def toggle_workshop_interest
def toggle_workshop_interest
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless workshop
return do_404 unless workshop
# save the current state
# save the current state
interested = workshop . interested? current_user
interested = workshop . interested? current_user
# remove all associated fields
# remove all associated fields
WorkshopInterest . delete_all ( :workshop_id = > workshop . id , :user_id = > current_user . id )
WorkshopInterest . delete_all ( workshop_id : workshop . id , user_id : current_user . id )
# creat the new interest row if we weren't interested before
# creat the new interest row if we weren't interested before
WorkshopInterest . create ( :workshop_id = > workshop . id , :user_id = > current_user . id ) unless interested
WorkshopInterest . create ( workshop_id : workshop . id , user_id : current_user . id ) unless interested
if request . xhr?
if request . xhr?
render json : [
render json : [
@ -192,13 +193,13 @@ class WorkshopsController < ApplicationController
]
]
else
else
# go back to the workshop
# go back to the workshop
redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
end
end
def facilitate_workshop
def facilitate_workshop
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless @workshop
return do_404 unless @workshop
return do_403 if @workshop . facilitator? ( current_user ) || ! current_user
return do_403 if @workshop . facilitator? ( current_user ) || ! current_user
@ -209,7 +210,7 @@ class WorkshopsController < ApplicationController
def facilitate_request
def facilitate_request
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless workshop
return do_404 unless workshop
return do_403 if workshop . facilitator? ( current_user ) || ! current_user
return do_403 if workshop . facilitator? ( current_user ) || ! current_user
@ -219,12 +220,12 @@ class WorkshopsController < ApplicationController
send_mail ( :workshop_facilitator_request , workshop . id , current_user . id , params [ :message ] )
send_mail ( :workshop_facilitator_request , workshop . id , current_user . id , params [ :message ] )
redirect_to sent_facilitate_workshop_url ( @this_conference . slug , workshop . id )
redirect_to sent_facilitate_workshop_path ( @this_conference . slug , workshop . id )
end
end
def sent_facilitate_request
def sent_facilitate_request
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
@workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless @workshop
return do_404 unless @workshop
return do_403 unless @workshop . requested_collaborator? ( current_user )
return do_403 unless @workshop . requested_collaborator? ( current_user )
@ -236,7 +237,7 @@ class WorkshopsController < ApplicationController
def approve_facilitate_request
def approve_facilitate_request
return do_403 unless logged_in?
return do_403 unless logged_in?
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless workshop . present?
return do_404 unless workshop . present?
@ -253,24 +254,24 @@ class WorkshopsController < ApplicationController
LinguaFranca . with_locale ( user . locale ) do
LinguaFranca . with_locale ( user . locale ) do
send_mail ( :workshop_facilitator_request_approved , workshop . id , user . id )
send_mail ( :workshop_facilitator_request_approved , workshop . id , user . id )
end
end
return redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
return redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
when :deny
when :deny
if workshop . active_facilitator? ( current_user ) && workshop . requested_collaborator? ( User . find ( user_id ) )
if workshop . active_facilitator? ( current_user ) && workshop . requested_collaborator? ( User . find ( user_id ) )
WorkshopFacilitator . delete_all (
WorkshopFacilitator . delete_all (
:workshop_id = > workshop . id ,
workshop_id : workshop . id ,
:user_id = > user_id )
user_id : user_id )
LinguaFranca . with_locale user . locale do
LinguaFranca . with_locale user . locale do
send_mail ( :workshop_facilitator_request_denied , workshop . id , user . id )
send_mail ( :workshop_facilitator_request_denied , workshop . id , user . id )
end
end
return redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
return redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
when :remove
when :remove
if workshop . can_remove? ( current_user , user )
if workshop . can_remove? ( current_user , user )
WorkshopFacilitator . delete_all (
WorkshopFacilitator . delete_all (
:workshop_id = > workshop . id ,
workshop_id : workshop . id ,
:user_id = > user_id )
user_id : user_id )
return redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
return redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
when :switch_ownership
when :switch_ownership
if workshop . creator? ( current_user )
if workshop . creator? ( current_user )
@ -282,7 +283,7 @@ class WorkshopsController < ApplicationController
workshop . id , user_id )
workshop . id , user_id )
f . role = :creator
f . role = :creator
f . save
f . save
return redirect_to view_workshop_url ( @this_conference . slug , workshop . id )
return redirect_to view_workshop_path ( @this_conference . slug , workshop . id )
end
end
end
end
@ -291,7 +292,7 @@ class WorkshopsController < ApplicationController
def add_workshop_facilitator
def add_workshop_facilitator
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
user = User . find_user ( params [ :email ] )
user = User . find_user ( params [ :email ] )
@ -313,12 +314,12 @@ class WorkshopsController < ApplicationController
end
end
end
end
return redirect_to view_workshop_url ( @this_conference . slug , params [ :workshop_id ] )
return redirect_to view_workshop_path ( @this_conference . slug , params [ :workshop_id ] )
end
end
def add_comment
def add_comment
set_conference
set_conference
set_conference_registration !
ensure_registration_is_complete !
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
workshop = Workshop . find_by_id_and_conference_id ( params [ :workshop_id ] , @this_conference . id )
return do_404 unless workshop && current_user
return do_404 unless workshop && current_user
@ -335,7 +336,7 @@ class WorkshopsController < ApplicationController
elsif params [ :button ] = 'add_comment'
elsif params [ :button ] = 'add_comment'
new_comment = workshop . add_comment ( current_user , params [ :comment ] )
new_comment = workshop . add_comment ( current_user , params [ :comment ] )
workshop . active_facilitators . each do | u |
workshop . active_facilitators . each do | u |
unless u . id == current_user . id
unless u . id == current_user . id
LinguaFranca . with_locale u . locale do
LinguaFranca . with_locale u . locale do
send_mail ( :workshop_comment , workshop . id , new_comment . id , u . id )
send_mail ( :workshop_comment , workshop . id , new_comment . id , u . id )
@ -346,20 +347,21 @@ class WorkshopsController < ApplicationController
return do_404
return do_404
end
end
return redirect_to view_workshop_url ( @this_conference . slug , workshop . id , anchor : " comment- #{ new_comment . id } " )
return redirect_to view_workshop_path ( @this_conference . slug , workshop . id , anchor : " comment- #{ new_comment . id } " )
end
end
rescue_from ActiveRecord :: PremissionDenied do | exception |
rescue_from ActiveRecord :: PremissionDenied do | exception |
if ! @this_conference . can_register?
if ! @this_conference . can_register?
do_404
do_404
elsif logged_in?
elsif logged_in?
redirect_to 'conferences/register'
flash [ :status_message ] = { message : :registration_required , status : :warning }
redirect_to register_path ( @this_conference . slug )
else
else
@register_template = :confirm_email
@register_template = :confirm_email
@page_title = " articles.conference_registration.headings. #{ @this_conference . registration_status == :open ? '' : 'Pre_' } Registration_Details "
@page_title = " articles.conference_registration.headings. #{ @this_conference . registration_status == :open ? '' : 'Pre_' } Registration_Details "
@main_title = " articles.conference_registration.headings. #{ @this_conference . registration_status == :open ? '' : 'Pre_' } Register "
@main_title = " articles.conference_registration.headings. #{ @this_conference . registration_status == :open ? '' : 'Pre_' } Register "
@main_title_vars = { vars : { title : @this_conference . title } }
@main_title_vars = { vars : { title : @this_conference . title } }
render 'conferences/register'
render register_path ( @this_conference . slug )
end
end
end
end