anteo / redmine_custom_workflows

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

Add All Project Members as Watchers #341

Closed Hernan22 closed 3 months ago

Hernan22 commented 3 months ago

How can I add all members of a project as watchers when an issue is created?

picman commented 3 months ago

Something like that as an after_save script might work:

if subject.present? && journals.all.size == 0
  project.members.each do |m|  
    add_watcher(m.user) unless watched_by?(m.user)
  end
end
Hernan22 commented 3 months ago

Thanks, it worked!

Hernan22 commented 4 weeks ago

Hello again, how can I exclude the 'cliente' role with ID 10 from being added to the watchers?

Best regards

picman commented 3 weeks ago
if subject.present? && journals.all.size == 0
  project.members.each do |m|  
    add_watcher(m.user) unless watched_by?(m.user) || m.role.id == 10
  end
end
Hernan22 commented 3 weeks ago

Thank you, but it doesn't work, it doesn't add anyone as followers.

picman commented 3 weeks ago

And is there a member who is not among watchers yet and hasn't got role id 10?