Skip to content

Commit

Permalink
use state_allows_xxx? instead of can_xxx?
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Nov 13, 2024
1 parent f68b44e commit 48e94de
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/models/sample_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,19 @@ def self.can_create?
can && (!Seek::Config.project_admin_sample_type_restriction || User.current_user.is_admin_or_project_administrator?)
end

def can_edit?(user = User.current_user)
def state_allows_edit?(*args)
super && !locked?
end

def can_manage?(user = User.current_user)
def state_allows_manage?(*args)
super && !locked?
end

def can_delete?(user = User.current_user)
# Should not be able to delete a sample type if it is locked
return false if locked?
def state_allows_delete?(*args)
super && !locked?
end

def can_delete?(user = User.current_user)
# Users should be able to delete an ISA JSON compliant sample type that has linked sample attributes,
# as long as it's ISA JSON compliant.
if is_isa_json_compliant?
Expand Down

0 comments on commit 48e94de

Please sign in to comment.