X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Flicense_group.rb;h=2fa5f67fa76f5a60764874af6ac8daf315860a8c;hb=69b61b39006c1951fc8c08746e884e63e50233b3;hp=cc09080d25403b93fca6ed633778eb690e7d3807;hpb=eb5aee94f87dd1a2c7ee7a5a6a0e88ae3e235166;p=pettanr%2Fpettanr.git diff --git a/app/models/license_group.rb b/app/models/license_group.rb index cc09080d..2fa5f67f 100644 --- a/app/models/license_group.rb +++ b/app/models/license_group.rb @@ -1,58 +1,24 @@ #ライセンスグループ -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 => {: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 - end - def supply_default end def overwrite end - def self.list - opt = {} - opt.merge!(self.list_opt) - 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, 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 - def self.show_json_opt - {:include => {:licenses => {}}} - end - def self.store name, attr #ライセンスデータがあるとライセンスグループのデータ生成で邪魔するので移しておく lattr = attr["licenses_attributes"]