fixed response in order to redirect correctly on ajax requests. Fixed policy

This commit is contained in:
Ralf Teusner
2017-04-18 16:51:02 +02:00
parent 51b4f1acbc
commit d053850572
3 changed files with 15 additions and 29 deletions

View File

@@ -1,38 +1,19 @@
class UserExerciseFeedbackPolicy < AdminOrAuthorPolicy
class UserExerciseFeedbackPolicy < ApplicationPolicy
def author?
@user == @record.author
end
private :author?
def batch_update?
admin?
end
def create?
everyone
end
def show?
@user.internal_user?
def new?
everyone
end
[:clone?, :destroy?, :edit?, :update?].each do |action|
[:show? ,:destroy?, :edit?, :update?].each do |action|
define_method(action) { admin? || author?}
end
[:reload?].each do |action|
define_method(action) { everyone }
end
class Scope < Scope
def resolve
if @user.admin?
@scope.all
elsif @user.internal_user?
@scope.where('user_id = ? OR public = TRUE', @user.id)
else
@scope.none
end
end
end
end