52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
class Admin::HonorTypesController < OrbitMemberController
|
|
before_action :allow_admin_only
|
|
|
|
def new
|
|
@honor_type = HonorType.new
|
|
@url = admin_honor_types_path(@honor_type)
|
|
render :layout=>false
|
|
end
|
|
|
|
def create
|
|
@honor_type = HonorType.new(honor_type_params)
|
|
@honor_type.save
|
|
@honor_types = HonorType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
def update_order
|
|
orders = params["order"]
|
|
HonorType.each do |ht|
|
|
ht.sort_position = orders["#{ht.id}"]
|
|
ht.save
|
|
end
|
|
render :json => {"success" => true}.to_json
|
|
end
|
|
|
|
def edit
|
|
@honor_type = HonorType.find(params[:id])
|
|
@url = admin_honor_type_path(@honor_type)
|
|
render :layout=>false
|
|
end
|
|
|
|
def update
|
|
@honor_type = HonorType.find(params[:id])
|
|
@honor_type.update_attributes(honor_type_params)
|
|
@honor_type.save
|
|
@honor_types = HonorType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
def destroy
|
|
honor_type = HonorType.find(params[:id])
|
|
honor_type.destroy
|
|
@honor_types = HonorType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
private
|
|
|
|
def honor_type_params
|
|
params.require(:honor_type).permit! rescue nil
|
|
end
|
|
end |