#
-class License < ActiveRecord::Base
+class License < Peta::Item
+ load_manifest
belongs_to :license_group
belongs_to :system_picture
+ has_many :resource_pictures
validates :license_group_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :name, :presence => true, :length => {:maximum => 50}
validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
- before_validation :valid_encode
+ def supply_default
+ end
- def valid_encode
- ['name', 'caption', 'url', 'settings', 'credit_pictures'].each do |a|
- next if attributes[a] == nil
- raise Pettanr::BadRequest unless attributes[a].valid_encoding?
- end
+ def overwrite
end
- def supply_default
+ def caption_with_group
+ self.license_group.caption + '/' + self.caption
end
- def overwrite
+ def self.list_where
+ ''
end
- def self.list
- opt = {}
- opt.merge!(License.list_opt)
- opt.merge!({:order => 'name'})
- License.find(:all, opt)
+ def self.list_order
+ 'licenses.name'
end
def self.list_opt
- {:include => {:license_group => {}}}
+ {:license_group => {}}
end
def self.list_json_opt
{:include => {:license_group => {}}}
end
- def self.show rid
- opt = {}
- opt.merge!(License.show_opt)
- res = License.find(rid, opt)
-# raise ActiveRecord::Forbidden unless res.visible?(au)
- res
- end
-
def self.show_opt
{:include => {:license_group => {}}}
end