added course add and edit
This commit is contained in:
parent
68558c166b
commit
eeb2b68def
|
@ -11,9 +11,41 @@ class Admin::InternationalRecruitsController < OrbitAdminController
|
||||||
redirect_to admin_international_recruits_path
|
redirect_to admin_international_recruits_path
|
||||||
end
|
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
|
def courses
|
||||||
@table_fields = ["international_recruit.course_name", "international_recruit.actions"]
|
@table_fields = ["international_recruit.course_name", "international_recruit.actions"]
|
||||||
@courses = UniversityCourse.all.asc(:created_at)
|
@courses = UniversityCourse.all.asc(:created_at)
|
||||||
end
|
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
|
end
|
|
@ -2,6 +2,7 @@ class InternationalRecruitsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
countries = []
|
countries = []
|
||||||
session = OrbitHelper.request.session
|
session = OrbitHelper.request.session
|
||||||
|
courses = UniversityCourse.all.asc(:created_at).collect{|uc| [uc.course_name]}
|
||||||
InternationalCountry::LIST.keys.each do |countrykey|
|
InternationalCountry::LIST.keys.each do |countrykey|
|
||||||
countries << [InternationalCountry::LIST[countrykey], countrykey]
|
countries << [InternationalCountry::LIST[countrykey], countrykey]
|
||||||
end
|
end
|
||||||
|
@ -15,7 +16,8 @@ class InternationalRecruitsController < ApplicationController
|
||||||
"countries" => countries,
|
"countries" => countries,
|
||||||
"years" => years,
|
"years" => years,
|
||||||
"member" => session["current_pseudo_user_id"],
|
"member" => session["current_pseudo_user_id"],
|
||||||
"login_url" => login_url
|
"login_url" => login_url,
|
||||||
|
"courses" => courses
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ class RecruitApplication
|
||||||
|
|
||||||
# //Course Choice//
|
# //Course Choice//
|
||||||
|
|
||||||
field :course_choice_one_id
|
field :course_choice_one
|
||||||
field :course_choice_two_id
|
field :course_choice_two
|
||||||
field :course_choice_three_id
|
field :course_choice_three
|
||||||
|
|
||||||
# //General Options//
|
# //General Options//
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<%= form_for @course, :url => {:action => "create_course"}, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||||
|
<div class="control-group">
|
||||||
|
<%= f.label :course_name, :class => "control-label muted" %>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :course_name %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.submit "Save", :class => "btn btn-primary" %>
|
||||||
|
<a class="btn btn-default" href="<%= courses_admin_international_recruits_path %>">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -10,13 +10,16 @@
|
||||||
<% @courses.each do |course| %>
|
<% @courses.each do |course| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= course.course_name %></td>
|
<td><%= course.course_name %></td>
|
||||||
<td></td>
|
<td>
|
||||||
|
<a href="<%= delete_course_admin_international_recruit_path(course) %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">Delete</a>
|
||||||
|
<a href="<%= edit_course_admin_international_recruit_path(course) %>" class="btn btn-warning">Edit</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="bottomnav clearfix">
|
<div class="bottomnav clearfix">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="" class="btn btn-primary">Add</a>
|
<a href="<%= add_course_admin_international_recruits_path %>" class="btn btn-primary" id="add-course">Add</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<%= form_for @course, :url => {:action => "update_course"}, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||||
|
<div class="control-group">
|
||||||
|
<%= f.label :course_name, :class => "control-label muted" %>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :course_name %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.submit "Save", :class => "btn btn-primary" %>
|
||||||
|
<a class="btn btn-default" href="<%= courses_admin_international_recruits_path %>">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -253,7 +253,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select name="Department" id="Department"></select>
|
<%= f.select :course_choice_one, data["courses"] %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -263,8 +263,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select name="Department_Two" id="Department_Two">
|
<%= f.select :course_choice_two, data["courses"] %>
|
||||||
</select>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -275,8 +274,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select name="Department_Three" id="Department_Three">
|
<%= f.select :course_choice_three, data["courses"] %>
|
||||||
</select>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -6,6 +6,13 @@ Rails.application.routes.draw do
|
||||||
resources :international_recruits do
|
resources :international_recruits do
|
||||||
collection do
|
collection do
|
||||||
get "courses"
|
get "courses"
|
||||||
|
get "add_course"
|
||||||
|
post "create_course"
|
||||||
|
end
|
||||||
|
member do
|
||||||
|
get "edit_course"
|
||||||
|
patch "update_course"
|
||||||
|
delete "delete_course"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue