OSDN Git Service

t#32046:
[pettanr/pettanr.git] / app / models / provider_license.rb
index 7c8efed..53e1e20 100644 (file)
@@ -1,10 +1,15 @@
 class ProviderLicense < ActiveRecord::Base
   belongs_to :provider
+  belongs_to :license, :foreign_key => :demanders_license_id
   
   validates :provider_id, :presence => true, :numericality => true, :existence => true
   validates :providers_license_id, :presence => true, :numericality => true
   validates :demanders_license_id, :presence => true, :numericality => true
   
+  def self.get_one pid, plid
+    ProviderLicense.find_by_provider_id_and_providers_license_id(pid, plid) || ProviderLicense.new
+  end
+  
   def self.exist_license pid, plid
     ProviderLicense.find_by_provider_id_and_providers_license_id(pid, plid) != nil
   end
@@ -27,7 +32,7 @@ class ProviderLicense < ActiveRecord::Base
       end
       raise ActiveRecord::Rollback if res.any?
     end
-    res
+    LicenseImportResult.new res
   end
   
 end