2015-03-18 22:02:38 +00:00
|
|
|
class KeyPairPolicy < ApplicationPolicy
|
|
|
|
|
|
|
|
def create?
|
2015-04-02 22:47:45 +01:00
|
|
|
return false unless record.repository
|
|
|
|
is_admin? || local_admin?(record.repository.platform)
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
2015-04-02 22:47:45 +01:00
|
|
|
alias_method :destroy?, :create?
|
2015-03-18 22:02:38 +00:00
|
|
|
|
2015-05-20 20:54:38 +01:00
|
|
|
# Public: Get list of parameters that the user is allowed to alter.
|
|
|
|
#
|
|
|
|
# Returns Array
|
|
|
|
def permitted_attributes
|
2015-05-20 22:19:47 +01:00
|
|
|
%i(public secret repository_id)
|
2015-05-20 20:54:38 +01:00
|
|
|
end
|
|
|
|
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|