created template selecting
This commit is contained in:
5
web/app/models/concerns/iconizable.rb
Normal file
5
web/app/models/concerns/iconizable.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Iconizable
|
||||
def safe_icon
|
||||
icon or 'chub.png'
|
||||
end
|
||||
end
|
||||
5
web/app/models/configuration_file.rb
Normal file
5
web/app/models/configuration_file.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ConfigurationFile < ActiveRecord::Base
|
||||
belongs_to :server
|
||||
belongs_to :file_type
|
||||
has_many :file_versions
|
||||
end
|
||||
6
web/app/models/configuration_template.rb
Normal file
6
web/app/models/configuration_template.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class ConfigurationTemplate < ActiveRecord::Base
|
||||
belongs_to :operating_system
|
||||
belongs_to :file_type
|
||||
|
||||
include Iconizable
|
||||
end
|
||||
3
web/app/models/file_type.rb
Normal file
3
web/app/models/file_type.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class FileType < ActiveRecord::Base
|
||||
has_many :configuration_files
|
||||
end
|
||||
3
web/app/models/file_version.rb
Normal file
3
web/app/models/file_version.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class FileVersion < ActiveRecord::Base
|
||||
belongs_to :configuration_file
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
class OperatingSystem < ActiveRecord::Base
|
||||
has_many :servers
|
||||
has_many :configuration_templates
|
||||
include Iconizable
|
||||
end
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
class Server < ActiveRecord::Base
|
||||
belongs_to :operating_system
|
||||
before_create :generate_hash
|
||||
has_many :configuration_files
|
||||
|
||||
def generate_hash
|
||||
self.namehash = SecureRandom.hex
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{name} - #{namehash}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user