diff --git a/app/controllers/admin/international_recruits_controller.rb b/app/controllers/admin/international_recruits_controller.rb index 52e5679..5cd6901 100644 --- a/app/controllers/admin/international_recruits_controller.rb +++ b/app/controllers/admin/international_recruits_controller.rb @@ -11,9 +11,41 @@ class Admin::InternationalRecruitsController < OrbitAdminController redirect_to admin_international_recruits_path end + def add_course + @course = UniversityCourse.new + end + + def create_course + course = UniversityCourse.new(course_params) + course.save + redirect_to courses_admin_international_recruits_path + end + + def edit_course + @course = UniversityCourse.find(params[:id]) + end + + def update_course + course = UniversityCourse.find(params[:id]) + course.update_attributes(course_params) + course.save + redirect_to courses_admin_international_recruits_path + end + def courses @table_fields = ["international_recruit.course_name", "international_recruit.actions"] @courses = UniversityCourse.all.asc(:created_at) end + def delete_course + course = UniversityCourse.find(params[:id]) + course.destroy + redirect_to courses_admin_international_recruits_path + end + + private + def course_params + params.require(:university_course).permit! + end + end \ No newline at end of file diff --git a/app/controllers/international_recruits_controller.rb b/app/controllers/international_recruits_controller.rb index fd29c95..cd0f1f1 100644 --- a/app/controllers/international_recruits_controller.rb +++ b/app/controllers/international_recruits_controller.rb @@ -2,6 +2,7 @@ class InternationalRecruitsController < ApplicationController def index countries = [] session = OrbitHelper.request.session + courses = UniversityCourse.all.asc(:created_at).collect{|uc| [uc.course_name]} InternationalCountry::LIST.keys.each do |countrykey| countries << [InternationalCountry::LIST[countrykey], countrykey] end @@ -15,7 +16,8 @@ class InternationalRecruitsController < ApplicationController "countries" => countries, "years" => years, "member" => session["current_pseudo_user_id"], - "login_url" => login_url + "login_url" => login_url, + "courses" => courses } end diff --git a/app/models/recruit_application.rb b/app/models/recruit_application.rb index eb6deca..d730b30 100644 --- a/app/models/recruit_application.rb +++ b/app/models/recruit_application.rb @@ -56,9 +56,9 @@ class RecruitApplication # //Course Choice// - field :course_choice_one_id - field :course_choice_two_id - field :course_choice_three_id + field :course_choice_one + field :course_choice_two + field :course_choice_three # //General Options// diff --git a/app/views/admin/international_recruits/add_course.html.erb b/app/views/admin/international_recruits/add_course.html.erb new file mode 100644 index 0000000..0c0b26d --- /dev/null +++ b/app/views/admin/international_recruits/add_course.html.erb @@ -0,0 +1,14 @@ +<%= form_for @course, :url => {:action => "create_course"}, html: {class: "form-horizontal main-forms"} do |f| %> +