seminar/app/controllers/admin/seminar_signups_controller.rb

72 lines
2.2 KiB
Ruby
Raw Normal View History

2016-06-29 06:57:45 +00:00
# encoding: utf-8
class Admin::SeminarSignupsController < OrbitAdminController
include Admin::SeminarsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :check_manager_for_seminar
2016-06-29 06:57:45 +00:00
def initialize
super
@app_title = "seminar"
end
def check_manager_for_seminar
OrbitHelper.set_params(params,current_user)
access_level = OrbitHelper.user_access_level?
if (access_level.nil? || access_level == "user")
@seminar = SeminarSignup.find(params[:id]).seminar_main rescue nil
if (@seminar.organizer_id != current_user.member_profile_id rescue true)
render_401
end
end
end
2016-06-29 06:57:45 +00:00
def edit
OrbitHelper.set_params(params,current_user)
2016-06-29 06:57:45 +00:00
params[:controller] = "admin/seminars"
@seminar_signup = SeminarSignup.find(params[:id])
@seminar = SeminarMain.find(@seminar_signup.seminar_main_id)
2023-10-04 16:38:24 +00:00
@form_index = 0
2016-06-29 06:57:45 +00:00
end
def update
2023-10-04 16:38:24 +00:00
2016-06-29 06:57:45 +00:00
@seminar_signup = SeminarSignup.find(params[:id])
@seminar_signup.update_attributes(seminar_signup_params)
if !params[:seminar_signup_values].nil?
params[:seminar_signup_values].each_with_index do |r,i|
field_value = r.last[:id].present?
@custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:id], field_value)
end
seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar_signup.seminar_main_id).to_a
seminar_reviews.each{|sr| sr.save}
@seminar = @seminar_signup.seminar_main
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
@seminar.seminar_reviews.each do |sr|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
end
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
@seminar.save
2016-06-29 06:57:45 +00:00
end
redirect_to "/admin/seminars/#{@seminar_signup.seminar_main_id}/seminar_signup"
end
def destroy
@seminar_signup = SeminarSignup.find(params[:id])
@seminar_main_id = @seminar_signup.seminar_main_id
@seminar_signup.destroy
2023-10-10 14:49:16 +00:00
redirect_to "/admin/seminars/#{@seminar_main_id}/seminar_signup?type=table"
2023-10-04 16:38:24 +00:00
end
2016-06-29 06:57:45 +00:00
private
def seminar_signup_params
params.require(:seminar_signup).permit!
end
end