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

Can one use plugin models in custom_workflows? #199

Closed letitbe13 closed 3 years ago

letitbe13 commented 3 years ago

Hi! We all have plugins that extend behavior of standart models like Project, Issue. Is it possible to add some "plugin driven" functionality to custom_workflow scenario? For example, I have redmine_dmsf plugin. I see in _redmine_dmsf/app/models/dmsffile.rb that

class DmsfFile < ActiveRecord::Base
  belongs_to :project
...
  validates :name, presence: true, dmsf_file_name: true

and in _redmine_dmsf/app/helpres/dmsf_linkshelper.rb example of access to dmsf files from project entity:

...
files = project.dmsf_files.visible.to_a if project

But, when I try to add in Project after_save something like files = self.dmsf_files it does nothing or throw a message "undefined method dmsf_files". Now I simply want to get number of files in project dmsf, and use it in done_ratio calculation. But else I want to understand the approach, how to use plugin logic within scenarios.

Thank you.

picman commented 3 years ago

But it works. I have the following code in project after save:

Rails.logger.info ">>> #{self.dmsf_files.all.size}"

After I change e.g. project's description and save the project, I can see in the log:

>>> 7
picman commented 3 years ago

Is the observable object really Project in your case?

letitbe13 commented 3 years ago

It works, Thank you. That was my inattention.