anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

inherited watchers(users/group) to subtask #291

Closed ashrafalzyoud closed 1 year ago

ashrafalzyoud commented 1 year ago

how i can inherited group watcher to subtask

AirTibu commented 1 year ago

Hi,

Use this code in AFTER_SAVE section:


unless self.parent.nil?
  self.parent.watcher_user_ids.each do |w_user|
      Watcher.create(:watchable_type=> 'Issue',:watchable_id=> self.id,:user_id=> w_user)
  end
end

I hope it helps!

ashrafalzyoud commented 1 year ago

I will test it Thx for your reply And we miss u @AirTibu

ashrafalzyoud commented 1 year ago

thx @AirTibu its work for me im using this example #161 how i can added group only as watcher without every on of user?? @AirTibu

AirTibu commented 1 year ago

Hi,

If you would like to add only the groups, than add a condition inside the loop, like this:


unless self.parent.nil?
  self.parent.watcher_user_ids.each do |w_user|
      Watcher.create(:watchable_type=> 'Issue',:watchable_id=> self.id,:user_id=> w_user) unless Group.find(w_user).nil?
  end
end

I hope it helps!

ashrafalzyoud commented 1 year ago
if self.assigned_to.is_a?(Group)
   arr = Array.new
   arr = Group.find(self.assigned_to_id).user_ids
   for item in arr
     self.add_watcher(User.find(item)) unless self.watched_by?(User.find(item))
   end
 end

how i can added Assignee group = group as wachers? this i want? @AirTibu im try this code

if self.assigned_to.is_a?(Group)
self.add_watcher(:watchable_type=> 'Issue',:watchable_id=> self.id,:user_id=> w_user) unless Group.find(w_user).nil?
end
AirTibu commented 1 year ago

Hi,

Use this code in AFTER_SAVE section:


self.add_watcher(self.assigned_to) unless self.assigned_to.nil? || Group.find(self.assigned_to.id).nil? 

I hope it helps!