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

Assignee group = all users from group as wachers? #161

Closed DolezalDavid closed 4 years ago

DolezalDavid commented 4 years ago

Hi, I have issue, where is a group as assignee. How do I set up all users from group as watchers?

I try edit this part from "Example Workflows" but unsuccessfully


# Add authors/assignees/updaters to Watchers
#
# Sets: Watcher

# = before_save = #
if subject.present?
    self.add_watcher(User.current) unless watched_by?(User.current)
end

# = after_save = #
# assignee - do this after save because assignee may
# be assigned by Category or by assignee plugin
if self.assigned_to.nil? || !self.assigned_to.is_a?(User) || self.assigned_to.anonymous? || !self.assigned_to.active?
  #do nothing
else
  self.add_watcher(self.assigned_to) unless self.watched_by?(self.assigned_to)
end

Can you help me with this please?

With best regards David

DolezalDavid commented 4 years ago

Nobody? It would be very useful... ;-)

DolezalDavid commented 4 years ago

OK, here is solution which work for me OK!

 # = after_save = #
 # assignee - do this after save because assignee may
 # be assigned by Category or by assignee plugin
 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
ashrafalzyoud commented 2 years ago

but must before check if the assigne have permision to added watcher?? becasue i have error msgwatcher unvalid @DolezalDavid