]> source.dussan.org Git - sonarqube.git/commitdiff
FIX we shouldn't be able to unfollow a non-shared dashboard
authorDavid Gageot <david@gageot.net>
Tue, 22 May 2012 17:13:55 +0000 (19:13 +0200)
committerDavid Gageot <david@gageot.net>
Tue, 22 May 2012 17:15:18 +0000 (19:15 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb

index 587c81fc80f5c427193451be8367daa2235b6b84..bf45f8149debc3ab76428527c51dae3bb75e1874 100644 (file)
@@ -135,10 +135,13 @@ class DashboardsController < ApplicationController
   def unfollow
     add_default_dashboards_if_first_user_dashboard
 
-    ActiveDashboard.destroy_all(['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i])
+    dashboard=Dashboard.find(:first, :conditions => ['shared=? and id=? and (user_id is null or user_id<>?)', true, params[:id].to_i, current_user.id])
+    if dashboard
+      ActiveDashboard.destroy_all(['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i])
 
-    if ActiveDashboard.count(:conditions => ['user_id=?', current_user.id])==0
-      flash[:notice]=Api::Utils.message('dashboard.default_restored')
+      if ActiveDashboard.count(:conditions => ['user_id=?', current_user.id])==0
+        flash[:notice]=Api::Utils.message('dashboard.default_restored')
+      end
     end
     redirect_to :action => 'index', :resource => params[:resource]
   end
index 23cb6fcbf608c0db0f8b07be8d23965aec7c4566..a213bae9df93f5988430e0efffee8aec77fec08f 100644 (file)
@@ -55,7 +55,7 @@
                               :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}", :class => 'link-action' %>
                 <% end %>
               <% end %>
-              <% if @actives.size() > 1 %>
+              <% if @actives.size() > 1 and active.shared? %>
                 |
                 <%= link_to message('unfollow'), {:action => :unfollow, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
                             :id => "unfollow-#{u active.name}", :class => 'link-action' %>