2015-03-18 22:02:38 +00:00
|
|
|
class IssuePolicy < ApplicationPolicy
|
|
|
|
|
|
|
|
def index?
|
2015-03-19 23:31:41 +00:00
|
|
|
# record.project.has_issues?
|
|
|
|
true
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
2015-04-06 22:55:51 +01:00
|
|
|
return false unless record.project.has_issues?
|
2015-03-25 00:17:17 +00:00
|
|
|
ProjectPolicy.new(user, record.project).show?
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
alias_method :create?, :show?
|
|
|
|
alias_method :read?, :show?
|
|
|
|
|
|
|
|
def update?
|
2015-04-10 23:35:36 +01:00
|
|
|
return false if user.guest?
|
2015-04-06 22:55:51 +01:00
|
|
|
is_admin? || record.user_id == user.id || local_admin?(record.project)
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|