#ライセンスグループ
-class LicenseGroup < ActiveRecord::Base
+class LicenseGroup < Peta::Template
+ load_manifest
+ has_many :resource_pictures
has_many :licenses
validates :name, :presence => true, :length => {:maximum => 50}, :uniqueness => true
- validates :classname, :presence => true, :length => {:maximum => 50}
+ validates :module_name, :presence => true, :length => {:maximum => 50}
validates :caption, :presence => true, :length => {:maximum => 30}
- validates :url, :presence => true, :length => {:maximum => 200}, :url => true
+ validates :url, :presence => true, :length => {:maximum => 200}, :url => {:message => I18n.t('errors.messages.url')}
+
+ def supply_default
+ end
+
+ def overwrite
+ end
+
+ def self.show_opt
+ {:include => {:licenses => {}}}
+ end
def self.store name, attr
#ライセンスデータがあるとライセンスグループのデータ生成で邪魔するので移しておく
r.save
#取っておいたライセンスデータとidでライセンス作成
if (c = License.stores(lattr, r.id)) > 0
- r.errors.add :base, 'licenses can not create'
+ r.errors.add :base, License.model_name.human + I18n.t('errors.not_create')
end
r
end
LicenseGroup.import_file(filename) {|name, attr| LicenseGroup.store(name, attr)}
end
- def self.list opt = {}
- opt.merge!(self.list_opt) unless opt[:include]
- opt.merge!({:order => 'license_groups.name asc'})
- LicenseGroup.find(:all, opt)
- end
-
- def self.list_opt
- {:include => {:licenses => {}}}
- end
-
- def self.list_json_opt
- {:include => {:licenses => {}}}
- end
-
- def self.show rid, opt = {}
- r = LicenseGroup.find(rid, :include => self.show_include_opt(opt))
-# raise ActiveRecord::Forbidden unless c.visible?(au)
- r
- end
-
- def self.show_include_opt opt = {}
- res = {:licenses => {}}
- res.push(opt[:include]) if opt[:include]
- res
- end
-
- def self.show_json_include_opt
- {:include => {:licenses => {}}}
- end
-
def self.disp_import_error r
if r == false
puts "json file error. file does not exist or broken"