Skip to content

Commit

Permalink
755919 - validation in activation key model, can't be created for Loc…
Browse files Browse the repository at this point in the history
…ker env
  • Loading branch information
Tomas Strachota committed Dec 8, 2011
1 parent 216c0d8 commit 39d1def
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/models/activation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ class ActivationKey < ActiveRecord::Base
validates :description, :katello_description_format => true
validates :environment, :presence => true
validate :environment_exists
validate :environment_not_locker

def environment_exists
errors.add(:environment, _("id: #{environment_id} doesn't exist ")) if environment.nil?
end

def environment_not_locker
errors.add(:base, _("Cannot create activation keys in Locker environment ")) if environment and environment.locker?
end

# set's up system when registering with this activation key
def apply_to_system(system)
system.environment_id = self.environment_id if self.environment_id
Expand Down

0 comments on commit 39d1def

Please sign in to comment.