summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-04-29 18:06:22 -0300
committerFelipe Artur <felipefac@gmail.com>2016-05-17 21:53:03 -0500
commit07ff874f572a947d7730787492a604dd3f44d496 (patch)
treee2182144eaeadbc54d408df9168f3ef220d16f27 /app
parent98d88e8188f551533390ca9dcb1247e5af6807cf (diff)
downloadgitlab-ce-07ff874f572a947d7730787492a604dd3f44d496.tar.gz
Let users set notification levels in projects which they are not members
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects_controller.rb4
-rw-r--r--app/models/user.rb9
2 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index f4ec60ad2c7..55632308b4f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -102,9 +102,7 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format|
format.html do
if current_user
- @membership = @project.team.find_member(current_user.id)
-
- if @membership
+ if can?(current_user, :read_project, @project)
@notification_setting = current_user.notification_settings_for(@project)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 368a3f3cfba..cc312a291c6 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -777,7 +777,14 @@ class User < ActiveRecord::Base
end
def notification_settings_for(source)
- notification_settings.find_or_initialize_by(source: source)
+ notification_setting = notification_settings.find_or_initialize_by({ source: source })
+
+ if source.is_a?(Project)
+ membership = source.team.find_member(self.id)
+ notification_setting.level = :disabled unless membership.present? || notification_setting.persisted?
+ end
+
+ notification_setting
end
private