SUZUKI Miho
null+****@clear*****
Wed Sep 19 19:51:36 JST 2012
SUZUKI Miho 2012-09-19 19:51:36 +0900 (Wed, 19 Sep 2012) New Revision: 65fdd1655c586dc576d16b1d921a8a86091c1a31 https://github.com/logaling/logaling-server/commit/65fdd1655c586dc576d16b1d921a8a86091c1a31 Merged c5d082c: Merge pull request #13 from logaling/enable-creating-user-glossary Log: Implement UserGlossariesController#show Modified files: app/controllers/user_glossaries_controller.rb app/models/term.rb app/models/user_glossary.rb app/views/user_glossaries/show.html.haml Modified: app/controllers/user_glossaries_controller.rb (+1 -0) =================================================================== --- app/controllers/user_glossaries_controller.rb 2012-09-19 18:44:58 +0900 (44cf28c) +++ app/controllers/user_glossaries_controller.rb 2012-09-19 19:51:36 +0900 (b8c632e) @@ -6,6 +6,7 @@ class UserGlossariesController < ApplicationController # GET /user_glossaries/1 # GET /user_glossaries/1.json def show + @user_glossary = UserGlossary.find(params[:id].to_i) end # GET /user_glossaries/new Modified: app/models/term.rb (+9 -0) =================================================================== --- app/models/term.rb 2012-09-19 18:44:58 +0900 (8e73b1b) +++ app/models/term.rb 2012-09-19 19:51:36 +0900 (70f8443) @@ -7,4 +7,13 @@ class Term attribute :note, type: String, default: '' validates_presence_of :source_term, :target_term + + def self.set_value(hash_value) + hash = hash_value.with_indifferent_access + term = Term.new + self.attributes.each do |key, value| + term[key] = hash[key] if hash[key].present? + end + term + end end Modified: app/models/user_glossary.rb (+6 -0) =================================================================== --- app/models/user_glossary.rb 2012-09-19 18:44:58 +0900 (6c1b1c6) +++ app/models/user_glossary.rb 2012-09-19 19:51:36 +0900 (7a45487) @@ -28,6 +28,12 @@ class UserGlossary < ActiveRecord::Base LogalingServer.repository.index end + def terms(annotation=nil) + glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + raise Logaling::GlossaryNotFound unless glossary + terms = glossary.terms(annotation).map { |term_hash| Term.set_value(term_hash) } + end + private def create_personal_project! LogalingServer.repository.create_personal_project(glossary_name, source_language, target_language) Modified: app/views/user_glossaries/show.html.haml (+13 -1) =================================================================== --- app/views/user_glossaries/show.html.haml 2012-09-19 18:44:58 +0900 (51a7539) +++ app/views/user_glossaries/show.html.haml 2012-09-19 19:51:36 +0900 (6751d70) @@ -1 +1,13 @@ -UserGlossary#show +.well + %h2 + = @user_glossary.glossary_name + = @user_glossary.source_language + = @user_glossary.target_language + %p + = link_to 'Add new term', new_user_glossary_term_path(user_id: current_user.id, glossary_id: @user_glossary.id), :class => 'btn btn-large btn-primary' + %p + - @user_glossary.terms.each do |term| + %li + = term.source_term + = term.target_term + = term.note -------------- next part -------------- An HTML attachment was scrubbed... Download