From 019182b2c2a088d8518ce1ffe814496098475c61 Mon Sep 17 00:00:00 2001
From: Lucas Ernesto Kindinger <lek@inf.ufpr.br>
Date: Thu, 24 Mar 2016 10:20:59 -0300
Subject: [PATCH] Fixed Review Button (Fix #21)

---
 app/views/collections/show.html.erb      | 5 ++++-
 app/views/learning_objects/show.html.erb | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb
index a82a07f8..632e8452 100644
--- a/app/views/collections/show.html.erb
+++ b/app/views/collections/show.html.erb
@@ -5,7 +5,10 @@
       <% if @own %>
           <% if @collection.class != Bookmark %>
               <%= link_to 'APAGAR', collection_path(@collection.id), method: :delete, class: 'btn btn-danger btn-remove', style: 'margin-right: 10px', data: {confirm: 'Não será possível recuperá-la, você tem certeza?'} %>
-              <%= link_to 'Avalie esta coleção!', new_review_path(reviewable_id: @collection.id, reviewable_type: @collection.class.name), class: 'btn btn-success', style: 'margin-right: 30px'  %>
+
+              <% if @collection.owner != current_user%>
+                <%= link_to 'Avalie esta coleção!', new_review_path(reviewable_id: @collection.id, reviewable_type: @collection.class.name), class: 'btn btn-success', style: 'margin-right: 30px'  %>
+              <% end -%>
               <div class="collection-privacy">
                 <input type="radio" name="privacy" id="privacy_private" data-cid="<%= @collection.id %>" value="private" <%= "checked" if @collection.privacy == "private" %>>
                 <label for="privacy_private">Privada</label> |
diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb
index 4d164f3b..4f7bb10a 100644
--- a/app/views/learning_objects/show.html.erb
+++ b/app/views/learning_objects/show.html.erb
@@ -153,7 +153,10 @@
     </div>
   </div>
 </div>
-<%= link_to 'Avalie este objeto!', new_review_path(reviewable_id: @learning_object.id, reviewable_type: @learning_object.class.name), class: 'btn btn-success'  %>
+
+<% if learning_object.owner != current_user %>
+  <%= link_to 'Avalie este objeto!', new_review_path(reviewable_id: @learning_object.id, reviewable_type: @learning_object.class.name), class: 'btn btn-success'  %>
+<% end -%>
 
 <br/><br/>
 <div class="row">
-- 
GitLab