Commit cad39298075dbfb33f1fb1910c5ba1adc7c217a4

Authored by Daniela Feitosa
1 parent de452eab

[suggestions] Disabling suggestion when ask to join

(ActionItem3432)
Showing 1 changed file with 9 additions and 0 deletions   Show diff stats
app/models/add_member.rb
... ... @@ -10,6 +10,10 @@ class AddMember < Task
10 10  
11 11 settings_items :roles
12 12  
  13 + after_create do |task|
  14 + remove_from_suggestion_list(task)
  15 + end
  16 +
13 17 def perform
14 18 if !self.roles or (self.roles.uniq.compact.length == 1 and self.roles.uniq.compact.first.to_i.zero?)
15 19 self.roles = [Profile::Roles.member(organization.environment.id).id]
... ... @@ -46,4 +50,9 @@ class AddMember < Task
46 50 _('You will need login to %{system} in order to accept or reject %{requestor} as a member of %{organization}.') % { :system => target.environment.name, :requestor => requestor.name, :organization => organization.name }
47 51 end
48 52  
  53 + def remove_from_suggestion_list(task)
  54 + suggestion = task.requestor.profile_suggestions.find_by_suggestion_id task.target.id
  55 + suggestion.disable if suggestion
  56 + end
  57 +
49 58 end
... ...