Application_Form/app/controllers/admin/seminar_submission_values_c...

46 lines
1.5 KiB
Ruby
Raw Normal View History

# encoding: utf-8
class Admin::SeminarSubmissionValuesController < OrbitAdminController
include Admin::SeminarsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_seminar,:check_manager_for_seminar
def initialize
super
@app_title = "seminar"
end
def set_seminar
@seminar_submission_value = SeminarSubmissionValue.find(params[:id]) rescue nil
@seminar_submission_field = @seminar_submission_value.seminar_submission_field rescue nil
@con = @seminar_submission_value.seminar_signup_contribute rescue nil
@seminar = @seminar_submission_value.seminar_submission_field.seminar_main rescue nil
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")
if (@seminar.organizer_id != current_user.member_profile_id rescue true)
render_401
end
end
end
def edit
OrbitHelper.set_params(params,current_user)
@form_index = 0
render :layout =>false
end
def update
begin
@seminar_submission_value.update_attributes(seminar_submission_value_params)
render :json => {:success=>true,:val=>@seminar_submission_value.get_value_by_locale(I18n.locale)}
rescue => e
render :json => {:success=>false,:error=>e.to_s}
end
end
private
def seminar_submission_value_params
params.require(:seminar_submission_values).permit!.values.first
end
end