Commit 1a58e308 authored by Jiri Strojil's avatar Jiri Strojil

FIxed policies

parent 5f1d5a96
class FeedbacksController < ApplicationController
def index
authorize Feedback
@feedbacks = if params[:assignment_id]
SemesterFeedback.where(assignment_id: params[:assignment_id])
elsif params[:group_offer_id]
......@@ -8,5 +7,7 @@ class FeedbacksController < ApplicationController
else
[]
end
authorize @feedbacks
@feedbacks = policy_scope(@feedbacks)
end
end
class FeedbackPolicy < ApplicationPolicy
class Scope < ApplicationScope
def resolve
return all if superadmin?
scope.where(volunteer: user.volunteer, author: user) if volunteer?
end
class Scope < ApplicationScope
def resolve
return all if superadmin?
scope.joins(:semester_process_volunteer, :volunteer).where(volunteers: {id: user.volunteer}) if volunteer?
end
end
alias_method :index?, :superadmin_or_volunteer?
end
alias_method :index?, :superadmin_or_volunteer?
alias_method :show?, :superadmin_or_feedback_about_volunteer?
end
\ No newline at end of file
class SemesterFeedbackPolicy < ApplicationPolicy
class Scope < ApplicationScope
def resolve
return all if superadmin?
scope.joins(:semester_process_volunteer, :volunteer).where(volunteers: {id: user.volunteer}) if volunteer?
end
end
# Actions
alias_method :review_semester?, :superadmin_or_volunteer?
alias_method :submit_review?, :superadmin_or_volunteer?
alias_method :index?, :superadmin_or_volunteer?
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment