aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorLuc Donnet2017-09-15 16:10:04 +0200
committerLuc Donnet2017-09-15 16:10:04 +0200
commit6dd60124b8b136b4b32abb835b16588e1b2492c0 (patch)
tree6b263e45de5e60865361fff2802b329ab9a464f9 /app/models
parent9e48ab0851290c65daaf212e3178bed1536b0bd7 (diff)
downloadchouette-core-6dd60124b8b136b4b32abb835b16588e1b2492c0.tar.bz2
Initialize first model for compliance_control STI Refs #3550 @4
Diffstat (limited to 'app/models')
-rw-r--r--app/models/compliance_control.rb5
-rw-r--r--app/models/generic_attribute_min_max.rb27
2 files changed, 31 insertions, 1 deletions
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 64556b524..12ff4737a 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -2,8 +2,11 @@ class ComplianceControl < ActiveRecord::Base
belongs_to :compliance_control_set
belongs_to :compliance_control_block
- enum criticity: [:info, :warning, :error]
+ extend Enumerize
+ enumerize :criticity, in: %i(info warning error), scope: true, default: :info
+
validates :criticity, presence: true
validates :name, presence: true
validates :code, presence: true
+ validates :compliance_control_set, presence: true
end
diff --git a/app/models/generic_attribute_min_max.rb b/app/models/generic_attribute_min_max.rb
new file mode 100644
index 000000000..e9a127c56
--- /dev/null
+++ b/app/models/generic_attribute_min_max.rb
@@ -0,0 +1,27 @@
+#module ComplianceControls
+
+ class GenericAttributeMinMax < ComplianceControl
+
+
+ hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
+ #attribute :minimum, type: :integer, optionnal: true
+ #attribute :maximum, type: :integer, optionnal: true
+ # #attribute :target, type: ModelAttribute
+
+ @@default_criticity = :warning
+ @@default_code = "3-Generic-2"
+
+ validate :min_max_values
+ def min_max_values
+ true
+ end
+
+ after_initialize do
+ self.name = 'GenericAttributeMinMax'
+ self.code = @@default_code
+ self.criticity = @@default_criticity
+ end
+
+ end
+
+#end