SHIMADA Koji
null+****@clear*****
Mon Oct 8 12:39:26 JST 2012
SHIMADA Koji 2012-10-08 12:39:26 +0900 (Mon, 08 Oct 2012) New Revision: 4f8eb79193c59f3cfed2703db892808e9380b8b3 https://github.com/logaling/logaling-server/commit/4f8eb79193c59f3cfed2703db892808e9380b8b3 Log: Show control panel only if signed in and glossary is current user's glossary Modified files: app/models/user.rb app/views/user_glossaries/show.html.haml Modified: app/models/user.rb (+4 -0) =================================================================== --- app/models/user.rb 2012-10-08 12:30:57 +0900 (a4f67ca) +++ app/models/user.rb 2012-10-08 12:39:26 +0900 (90b1c06) @@ -29,4 +29,8 @@ class User < ActiveRecord::Base def priority_glossary user_config ? user_config.glossary : nil end + + def own?(user_glossary) + user_glossaries.include?(user_glossary) + end end Modified: app/views/user_glossaries/show.html.haml (+9 -7) =================================================================== --- app/views/user_glossaries/show.html.haml 2012-10-08 12:30:57 +0900 (5a5711b) +++ app/views/user_glossaries/show.html.haml 2012-10-08 12:39:26 +0900 (9c4128e) @@ -4,10 +4,11 @@ = "#{@user.name} / #{@user_glossary.title_text}" %p = @user_glossary.description - %h2 - 用語を登録 - .well - = render 'terms/form' + - if signed_in? && current_user.own?(@user_glossary) + %h2 + 用語を登録 + .well + = render 'terms/form' %h2 登録されてる用語一覧 - @registered_terms.each do |term| @@ -26,7 +27,8 @@ .span2.property %p.logalingProject = @user_glossary.link_text - %p.btn-group.actions - = link_to raw("<i class=icon-pencil></i>"), edit_user_glossary_term_path(current_user, @user_glossary, term.id), :class => 'btn btn-mini' - = link_to raw("<i class=icon-trash></i>"), user_glossary_term_path(current_user, @user_glossary, term.id), method: :delete, :class => 'btn btn-mini' + - if signed_in? && current_user.own?(@user_glossary) + %p.btn-group.actions + = link_to raw("<i class=icon-pencil></i>"), edit_user_glossary_term_path(current_user, @user_glossary, term.id), :class => 'btn btn-mini' + = link_to raw("<i class=icon-trash></i>"), user_glossary_term_path(current_user, @user_glossary, term.id), method: :delete, :class => 'btn btn-mini' = paginate @registered_terms -------------- next part -------------- An HTML attachment was scrubbed... Télécharger