[logaling-commit] logaling/logaling-server [add-github-project-glossaries-to-priority-glossary] Add glossaries on github project to priority glossary target

Back to archive index

SHIMADA Koji null+****@clear*****
Wed Sep 26 13:55:08 JST 2012


SHIMADA Koji	2012-09-26 13:55:08 +0900 (Wed, 26 Sep 2012)

  New Revision: 384135ce312b3d4b13a1a285b6c70f702142dc20
  https://github.com/logaling/logaling-server/commit/384135ce312b3d4b13a1a285b6c70f702142dc20

  Log:
    Add glossaries on github project to priority glossary target

  Modified files:
    app/decorators/user_config_decorator.rb
    app/models/user_config.rb
    app/views/dashboard/show.html.haml

  Modified: app/decorators/user_config_decorator.rb (+2 -2)
===================================================================
--- app/decorators/user_config_decorator.rb    2012-09-26 13:40:26 +0900 (45c79a0)
+++ app/decorators/user_config_decorator.rb    2012-09-26 13:55:08 +0900 (3a2a1da)
@@ -1,7 +1,7 @@
 # coding: utf-8
 module UserConfigDecorator
-  def mark_for(user_glossary)
-    same?(user_glossary) ? "★" : "☆"
+  def mark_for(glossary)
+    same?(glossary) ? "★" : "☆"
   end
 
   def submit_path_for(user)

  Modified: app/models/user_config.rb (+10 -4)
===================================================================
--- app/models/user_config.rb    2012-09-26 13:40:26 +0900 (220b597)
+++ app/models/user_config.rb    2012-09-26 13:55:08 +0900 (955a322)
@@ -5,10 +5,16 @@ class UserConfig < ActiveRecord::Base
 
   belongs_to :user
 
-  def same?(user_glossary)
-    glossary_name == user_glossary.glossary_name &&
-    source_language == user_glossary.source_language &&
-    target_language == user_glossary.target_language
+  def same?(glossary)
+    if glossary.respond_to?(:glossary_name)
+      glossary_name == glossary.glossary_name &&
+      source_language == glossary.source_language &&
+      target_language == glossary.target_language
+    else
+      glossary_name == glossary.name &&
+      source_language == glossary.source_language &&
+      target_language == glossary.target_language
+    end
   end
 
   def glossary

  Modified: app/views/dashboard/show.html.haml (+9 -0)
===================================================================
--- app/views/dashboard/show.html.haml    2012-09-26 13:40:26 +0900 (7cd511f)
+++ app/views/dashboard/show.html.haml    2012-09-26 13:55:08 +0900 (61c1adb)
@@ -23,3 +23,12 @@
       - @github_projects.each do |github_project|
         %li
           = github_project.full_name
+          %ul
+            - github_project.glossaries.each do |glossary|
+              %li
+                = glossary
+                = form_for @user_config, url: @user_config.submit_path_for(current_user) do |f|
+                  = f.hidden_field :glossary_name, value: glossary.name
+                  = f.hidden_field :source_language, value: glossary.source_language
+                  = f.hidden_field :target_language, value: glossary.target_language
+                  = f.submit @user_config.mark_for(glossary), :class => 'btn btn-link'
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Back to archive index