[logaling-commit] logaling/logaling-server [master] Use Repository#find_glossary for finding glossary

Zurück zum Archiv-Index

SHIMADA Koji null+****@clear*****
Thu Sep 20 10:15:45 JST 2012


SHIMADA Koji	2012-09-20 10:15:45 +0900 (Thu, 20 Sep 2012)

  New Revision: 1f4664f4042dd85f9de5338821f6a5fcaae8b1be
  https://github.com/logaling/logaling-server/commit/1f4664f4042dd85f9de5338821f6a5fcaae8b1be

  Merged c5d082c: Merge pull request #13 from logaling/enable-creating-user-glossary

  Log:
    Use Repository#find_glossary for finding glossary

  Modified files:
    app/models/user_glossary.rb

  Modified: app/models/user_glossary.rb (+12 -15)
===================================================================
--- app/models/user_glossary.rb    2012-09-19 23:40:54 +0900 (b0d4921)
+++ app/models/user_glossary.rb    2012-09-20 10:15:45 +0900 (431b5a1)
@@ -14,12 +14,11 @@ class UserGlossary < ActiveRecord::Base
   end
 
   def add!(term)
-    project = LogalingServer.repository.find_project(glossary_name)
-    raise Logaling::ProjectNotFound unless project
-    raise Logaling::ProjectNotFound if project.class.name == 'Logaling::ImportedProject'
-
     raise Logaling::TermError unless term.valid?
-    glossary = project.glossary(source_language, target_language)
+
+    glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language)
+    raise Logaling::GlossaryNotFound unless glossary
+
     if glossary.bilingual_pair_exists?(term.source_term, term.target_term)
       raise Logaling::TermError, "term '#{term.source_term}: #{term.target_term}' already exists in '#{name}'"
     end
@@ -29,12 +28,11 @@ class UserGlossary < ActiveRecord::Base
   end
 
   def update(term, new_term)
-    project = LogalingServer.repository.find_project(glossary_name)
-    raise Logaling::ProjectNotFound unless project
-    raise Logaling::ProjectNotFound if project.class.name == 'Logaling::ImportedProject'
-
     raise Logaling::TermError unless term.valid?
-    glossary = project.glossary(source_language, target_language)
+
+    glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language)
+    raise Logaling::GlossaryNotFound unless glossary
+
     unless glossary.bilingual_pair_exists?(term.source_term, term.target_term)
       raise Logaling::TermError, "term '#{term.source_term}: #{term.target_term}' doesn't exist in '#{name}'"
     end
@@ -44,12 +42,11 @@ class UserGlossary < ActiveRecord::Base
   end
 
   def delete(term)
-    project = LogalingServer.repository.find_project(glossary_name)
-    raise Logaling::ProjectNotFound unless project
-    raise Logaling::ProjectNotFound if project.class.name == 'Logaling::ImportedProject'
-
     raise Logaling::TermError unless term.valid?
-    glossary = project.glossary(source_language, target_language)
+
+    glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language)
+    raise Logaling::GlossaryNotFound unless glossary
+
     unless glossary.bilingual_pair_exists?(term.source_term, term.target_term)
       raise Logaling::TermError, "term '#{term.source_term}: #{term.target_term}' doesn't exist in '#{name}'"
     end
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Zurück zum Archiv-Index