diff --git a/app/controllers/inter_library_loans_controller.rb b/app/controllers/inter_library_loans_controller.rb
index 3b7401c..7104171 100644
--- a/app/controllers/inter_library_loans_controller.rb
+++ b/app/controllers/inter_library_loans_controller.rb
@@ -1,7 +1,8 @@
class InterLibraryLoansController < ApplicationController
- load_and_authorize_resource
- before_filter :get_item
- before_filter :store_page, :only => :index
+ before_action :set_inter_library_loan, only: [:show, :edit, :update, :destroy]
+ before_action :check_policy, only: [:index, :new, :create]
+ before_action :get_item
+ before_action :store_page, :only => :index
# GET /inter_library_loans
# GET /inter_library_loans.json
@@ -120,6 +121,15 @@ def destroy
end
private
+ def set_inter_library_loan
+ @inter_library_loan = InterLibraryLoan.find(params[:id])
+ authorize @inter_library_loan
+ end
+
+ def check_policy
+ authorize InterLibraryLoan
+ end
+
def inter_library_loan_params
params.require(:inter_library_loan).permit(:item_id, :borrowing_library_id)
end
diff --git a/app/models/enju_inter_library_loan/ability.rb b/app/models/enju_inter_library_loan/ability.rb
deleted file mode 100644
index 047d5a5..0000000
--- a/app/models/enju_inter_library_loan/ability.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module EnjuInterLibraryLoan
- class Ability
- include CanCan::Ability
-
- def initialize(user, ip_address = nil)
- case user.try(:role).try(:name)
- when 'Administrator'
- can :manage, InterLibraryLoan
- when 'Librarian'
- can :manage, InterLibraryLoan
- end
- end
- end
-end
diff --git a/app/policies/inter_library_loan_policy.rb b/app/policies/inter_library_loan_policy.rb
index 07dc601..04ccc5e 100644
--- a/app/policies/inter_library_loan_policy.rb
+++ b/app/policies/inter_library_loan_policy.rb
@@ -1,4 +1,12 @@
-class InterLibraryLoanPolicy < AdminPolicy
+class InterLibraryLoanPolicy < ApplicationPolicy
+ def index?
+ user.try(:has_role?, 'Librarian')
+ end
+
+ def show?
+ user.try(:has_role?, 'Librarian')
+ end
+
def create?
user.try(:has_role?, 'Librarian')
end
diff --git a/app/views/inter_library_loans/index.html.erb b/app/views/inter_library_loans/index.html.erb
index d6e06e1..1fa48d2 100644
--- a/app/views/inter_library_loans/index.html.erb
+++ b/app/views/inter_library_loans/index.html.erb
@@ -26,7 +26,7 @@
<%= l(inter_library_loan.shipped_at) if inter_library_loan.shipped_at -%>
<%= l(inter_library_loan.received_at) if inter_library_loan.received_at -%>
- <%- if can? :destroy, inter_library_loan -%>
+ <%- if policy(inter_library_loan).destroy? -%>