summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-09 19:02:30 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-09 19:02:30 -0700
commitde629b4835f3ac6feac6bd567cee3ec79eb2b7d0 (patch)
tree176cbbbeb7cc6f3fd689d06aa7ffec88137801f9
parentfcaf0a89e8f4be206b0378c32fd683e1cf15f804 (diff)
downloadgitlab-ce-de629b4835f3ac6feac6bd567cee3ec79eb2b7d0.tar.gz
Blocking user does not remove him/her from project/groups but show blocked label
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/user.rb20
-rw-r--r--app/services/notification_service.rb1
-rw-r--r--app/views/admin/users/show.html.haml1
-rw-r--r--app/views/groups/group_members/_group_member.html.haml3
-rw-r--r--app/views/projects/team_members/_team_member.html.haml5
6 files changed, 9 insertions, 22 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b210a6b0155..81468d4013e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@ v 7.9.0 (unreleased)
- Automatically link commit ranges to compare page: sha1...sha4 or sha1..sha4 (includes sha1 in comparison)
- Move groups page from profile to dashboard
- Starred projects page at dashboard
+ - Blocking user does not remove him/her from project/groups but show blocked label
v 7.8.2
- Fix service migration issue when upgrading from versions prior to 7.3
diff --git a/app/models/user.rb b/app/models/user.rb
index 51dd6332fdb..0d40ac8309e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -154,24 +154,6 @@ class User < ActiveRecord::Base
delegate :path, to: :namespace, allow_nil: true, prefix: true
state_machine :state, initial: :active do
- after_transition any => :blocked do |user, transition|
- # Remove user from all projects and
- user.project_members.find_each do |membership|
- # skip owned resources
- next if membership.project.owner == user
-
- return false unless membership.destroy
- end
-
- # Remove user from all groups
- user.group_members.find_each do |membership|
- # skip owned resources
- next if membership.group.last_owner?(user)
-
- return false unless membership.destroy
- end
- end
-
event :block do
transition active: :blocked
end
@@ -626,7 +608,7 @@ class User < ActiveRecord::Base
def contributed_projects_ids
Event.where(author_id: self).
where("created_at > ?", Time.now - 1.year).
- where("action = :pushed OR (target_type = 'MergeRequest' AND action = :created)",
+ where("action = :pushed OR (target_type = 'MergeRequest' AND action = :created)",
pushed: Event::PUSHED, created: Event::CREATED).
reorder(project_id: :desc).
select(:project_id).
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 2fc63b9f4b7..0063b7ce40c 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -268,6 +268,7 @@ class NotificationService
# Also remove duplications and nil recipients
def reject_muted_users(users, project = nil)
users = users.to_a.compact.uniq
+ users = users.reject(&:blocked?)
users.reject do |user|
next user.notification.disabled? unless project
diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml
index bae9a97bf36..90c9f8c2f9b 100644
--- a/app/views/admin/users/show.html.haml
+++ b/app/views/admin/users/show.html.haml
@@ -116,7 +116,6 @@
%ul
%li User will not be able to login
%li User will not be able to access git repositories
- %li User will be removed from joined projects and groups
%li Personal projects will be left
%li Owned groups will be left
%br
diff --git a/app/views/groups/group_members/_group_member.html.haml b/app/views/groups/group_members/_group_member.html.haml
index 30c3c2b00df..6267006f63f 100644
--- a/app/views/groups/group_members/_group_member.html.haml
+++ b/app/views/groups/group_members/_group_member.html.haml
@@ -8,6 +8,9 @@
%span.cgray= user.username
- if user == current_user
%span.label.label-success It's you
+ - if user.blocked?
+ %label.label.label-danger
+ %strong Blocked
- if show_roles
%span.pull-right
diff --git a/app/views/projects/team_members/_team_member.html.haml b/app/views/projects/team_members/_team_member.html.haml
index 61c50af31bf..eb815447407 100644
--- a/app/views/projects/team_members/_team_member.html.haml
+++ b/app/views/projects/team_members/_team_member.html.haml
@@ -12,6 +12,7 @@
= image_tag avatar_icon(user.email, 32), class: "avatar s32"
%p
%strong= user.name
+ - if user.blocked?
+ %label.label.label-danger
+ %strong Blocked
%span.cgray= user.username
-
-