Built-in user_attribute_models
This commit is contained in:
1 parent
509c106b3e
commit
83bbd77d96
14 files changed
+78
-20
No files matched your search
@@ -8,6 +8,8 @@ class AttributeModel
|
||||
field :markup
|
||||
field :locale, :type => Boolean
|
||||
field :list_options, :type => Array
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embedded_in :user_attribute_model, :inverse_of => :attribute_models
|
||||
validates_uniqueness_of :key
|
||||
@@ -47,5 +49,13 @@ class AttributeModel
|
||||
def should_destroy?
|
||||
should_destroy.to_i == 1 rescue nil
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5,6 +5,8 @@ class UserAttributeModel
|
||||
|
||||
field :key
|
||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embeds_many :attribute_models
|
||||
|
||||
@@ -46,6 +48,18 @@ class UserAttributeModel
|
||||
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
def get_enabled_attribute_models
|
||||
self.attribute_models.excludes('disabled' => true)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Destroy the i18n_variable for each attribute_models if marked to destroy
|
||||
|
||||
Reference in new issue
Block a user