socialforge/lib/trustie/gitlab/manage_member.rb

43 lines
956 B
Ruby
Raw Normal View History

2015-08-01 20:09:53 +08:00
#coding=utf-8
#
#
module Trustie
module Gitlab
module ManageMember
def self.included(base)
base.class_eval {
before_create :add_gitlab_member
before_destroy :delete_gitlab_member
after_save :change_gitlab_member
}
end
def change_gitlab_member
if self.member.project_id == 2
@g ||= ::Gitlab.client
@g.edit_team_member(11, self.member.user.gid, self.role.to_gitlab_role )
end
end
def add_gitlab_member
if self.member.project_id == 2
@g ||= ::Gitlab.client
@g.add_team_member(11, self.member.user.gid, self.role.to_gitlab_role )
end
end
def delete_gitlab_member
if member.roles.count <=1
if self.member.project_id == 2
@g ||= ::Gitlab.client
@g.remove_team_member(11, self.member.user.gid)
end
end
end
end
end
end