#ライセンスグループ
-class LicenseGroup < ActiveRecord::Base
+class LicenseGroup < Pettanr::Item
has_many :licenses
validates :name, :presence => true, :length => {:maximum => 50}, :uniqueness => true
validates :caption, :presence => true, :length => {:maximum => 30}
validates :url, :presence => true, :length => {:maximum => 200}, :url => {:message => I18n.t('errors.messages.url')}
- before_validation :valid_encode
-
- def valid_encode
- ['name', 'classname', 'caption', 'url'].each do |a|
- next if attributes[a] == nil
- raise Pettanr::BadRequest unless attributes[a].valid_encoding?
- end
+ def self.valid_encode_columns
+ super + ['name', 'classname', 'caption', 'url']
end
def supply_default
def overwrite
end
- def self.list
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:order => 'license_groups.name asc'})
- LicenseGroup.find(:all, opt)
+ def self.list_where
+ ''
+ end
+
+ def self.list_order
+ 'license_groups.name asc'
+ end
+
+ def self.enable_list
+ LicenseGroup.find(:all).delete_if {|lg|
+ lg.enable? == false
+ }
end
def self.list_opt
{:include => {:licenses => {}}}
end
- def self.show rid, roles = nil
- opt = {}
- opt.merge!(self.show_opt)
- res = LicenseGroup.find(rid, opt)
-# raise ActiveRecord::Forbidden unless res.visible?(au)
- res
- end
-
def self.show_opt
{:include => {:licenses => {}}}
end
{:include => {:licenses => {}}}
end
+ def my_engine_resource
+ Manifest.manifest.system_resources.engine_resources['system_resources']
+ end
+
+ def engine_name
+ self.my_engine_resource.resource_items[self.classname]
+ end
+
+ def enable?
+ self.my_engine_resource.resource_items.include? self.classname
+ end
+
+ def engine_module_name
+ self.engine_name.camelize
+ end
+
+ def engine
+ Object.const_get self.engine_module_name
+ end
def self.store name, attr
#ライセンスデータがあるとライセンスグループのデータ生成で邪魔するので移しておく
lattr = attr["licenses_attributes"]