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

HELP: Add each member of specific group as watchers if User.current member of that group #173

Closed tanertas closed 4 years ago

tanertas commented 4 years ago

I want to accomplish this with this plugin: Check if a regular user member of a specific Group, if true, then add each member of the Group as watchers during issue creation.

tanertas commented 4 years ago

I got response from redmine forum: https://www.redmine.org/boards/2/topics/59441

The code below works as expected:

if subject.present?
  group = Group.find(21) 
  if User.current.is_or_belongs_to?(group)
    group.users.each {|user| self.add_watcher(user) unless watched_by?(user)}
  end
end