delete invited users when removed from project

pull/3480/head
Markus Kahl 9 years ago
parent 3428181894
commit 3738329078
  1. 9
      app/controllers/members_controller.rb
  2. 7
      app/models/member.rb

@ -117,8 +117,13 @@ class MembersController < ApplicationController
def destroy
if @member.deletable?
@member.destroy
flash.notice = l(:notice_member_removed)
if @member.disposable?
@member.user.destroy
flash.notice = I18n.t(:notice_member_removed)
else
@member.destroy
flash.notice = I18n.t(:notice_member_removed)
end
end
redirect_to project_members_path(project_id: @project)

@ -130,6 +130,13 @@ class Member < ActiveRecord::Base
@membership
end
##
# Returns true if this user can be deleted as they have no other memberships
# and haven't been activated yet.
def disposable?
user.invited? && user.memberships.none? { |m| m.project_id != project_id }
end
protected
def destroy_if_no_roles_left!

Loading…
Cancel
Save