diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index b0e35423..aadd9f29 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -46,11 +46,19 @@ module RedmineDmsf :class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy has_many :dmsf_links, -> { where dmsf_folder_id: nil }, :class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy + + before_save :set_default_dmsf_notification end end module InstanceMethods + def set_default_dmsf_notification + if self.new_record? + self.dmsf_notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'] == '1' + end + end + def dmsf_count file_count = self.dmsf_files.visible.count + self.file_links.visible.count folder_count = self.dmsf_folders.visible.count + self.folder_links.visible.count