Too many notifications
This commit is contained in:
parent
16949cc3d4
commit
10d3497e54
@ -22,7 +22,7 @@
|
|||||||
module DmsfUploadHelper
|
module DmsfUploadHelper
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def self.commit_files_internal(commited_files, project, folder, controller = nil)
|
def self.commit_files_internal(commited_files, project, folder, controller = nil, new_object = false, container = nil)
|
||||||
failed_uploads = []
|
failed_uploads = []
|
||||||
files = []
|
files = []
|
||||||
if commited_files
|
if commited_files
|
||||||
@ -106,29 +106,29 @@ module DmsfUploadHelper
|
|||||||
FileUtils.mv commited_file[:tempfile_path], new_revision.disk_file(false)
|
FileUtils.mv commited_file[:tempfile_path], new_revision.disk_file(false)
|
||||||
FileUtils.chmod 'u=wr,g=r', new_revision.disk_file(false)
|
FileUtils.chmod 'u=wr,g=r', new_revision.disk_file(false)
|
||||||
file.set_last_revision new_revision
|
file.set_last_revision new_revision
|
||||||
files.push(file)
|
files.push file
|
||||||
if file.container.is_a?(Issue)
|
if container && container.is_a?(Issue) && (!new_object)
|
||||||
file.container.dmsf_file_added(file)
|
container.dmsf_file_added file
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error e.message
|
Rails.logger.error e.message
|
||||||
controller.flash[:error] = e.message if controller
|
controller.flash[:error] = e.message if controller
|
||||||
failed_uploads.push(file)
|
failed_uploads.push file
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
failed_uploads.push(commited_file)
|
failed_uploads.push commited_file
|
||||||
end
|
end
|
||||||
# Approval workflow
|
# Approval workflow
|
||||||
if commited_file[:workflow_id].present?
|
if commited_file[:workflow_id].present?
|
||||||
wf = DmsfWorkflow.find_by(id: commited_file[:workflow_id])
|
wf = DmsfWorkflow.find_by(id: commited_file[:workflow_id])
|
||||||
if wf
|
if wf
|
||||||
# Assign the workflow
|
# Assign the workflow
|
||||||
new_revision.set_workflow(wf.id, 'assign')
|
new_revision.set_workflow wf.id, 'assign'
|
||||||
new_revision.assign_workflow(wf.id)
|
new_revision.assign_workflow wf.id
|
||||||
# Start the workflow
|
# Start the workflow
|
||||||
new_revision.set_workflow(wf.id, 'start')
|
new_revision.set_workflow wf.id, 'start'
|
||||||
if new_revision.save
|
if new_revision.save
|
||||||
wf.notify_users(project, new_revision, controller)
|
wf.notify_users project, new_revision, controller
|
||||||
begin
|
begin
|
||||||
file.lock!
|
file.lock!
|
||||||
rescue DmsfLockError => e
|
rescue DmsfLockError => e
|
||||||
|
|||||||
@ -142,9 +142,6 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
# Revisions and links of a deleted file SHOULD be deleted too
|
# Revisions and links of a deleted file SHOULD be deleted too
|
||||||
dmsf_file_revisions.each { |r| r.delete(commit, true) }
|
dmsf_file_revisions.each { |r| r.delete(commit, true) }
|
||||||
if commit
|
if commit
|
||||||
if container.is_a?(Issue)
|
|
||||||
container.dmsf_file_removed(self)
|
|
||||||
end
|
|
||||||
destroy
|
destroy
|
||||||
else
|
else
|
||||||
self.deleted = STATUS_DELETED
|
self.deleted = STATUS_DELETED
|
||||||
@ -555,13 +552,4 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
l(:title_unlock_file)
|
l(:title_unlock_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def container
|
|
||||||
unless @container
|
|
||||||
if dmsf_folder && dmsf_folder.system
|
|
||||||
@container = Issue.find_by(id: dmsf_folder.title.to_i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@container
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -126,17 +126,8 @@ class DmsfLink < ActiveRecord::Base
|
|||||||
link
|
link
|
||||||
end
|
end
|
||||||
|
|
||||||
def container
|
|
||||||
if dmsf_folder && dmsf_folder.system
|
|
||||||
Issue.find_by id: dmsf_folder.title
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete(commit = false)
|
def delete(commit = false)
|
||||||
if commit
|
if commit
|
||||||
if container.is_a?(Issue)
|
|
||||||
container.dmsf_file_removed(target_file)
|
|
||||||
end
|
|
||||||
destroy
|
destroy
|
||||||
else
|
else
|
||||||
self.deleted = STATUS_DELETED
|
self.deleted = STATUS_DELETED
|
||||||
|
|||||||
@ -67,6 +67,7 @@ module RedmineDmsf
|
|||||||
def controller_issues_before_save(context)
|
def controller_issues_before_save(context)
|
||||||
if context.is_a?(Hash)
|
if context.is_a?(Hash)
|
||||||
issue = context[:issue]
|
issue = context[:issue]
|
||||||
|
@new_object = issue.new_record?
|
||||||
params = context[:params]
|
params = context[:params]
|
||||||
# Save upload preferences DMS/Attachments
|
# Save upload preferences DMS/Attachments
|
||||||
User.current.pref.update_attribute :dmsf_attachments_upload_choice, params[:dmsf_attachments_upload_choice]
|
User.current.pref.update_attribute :dmsf_attachments_upload_choice, params[:dmsf_attachments_upload_choice]
|
||||||
@ -144,7 +145,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
DmsfUploadHelper.commit_files_internal uploaded_files, issue.project, system_folder,
|
DmsfUploadHelper.commit_files_internal uploaded_files, issue.project, system_folder,
|
||||||
context[:controller]
|
context[:controller], @new_object, issue
|
||||||
end
|
end
|
||||||
# Attach DMS links
|
# Attach DMS links
|
||||||
issue.saved_dmsf_links.each do |l|
|
issue.saved_dmsf_links.each do |l|
|
||||||
@ -154,7 +155,7 @@ module RedmineDmsf
|
|||||||
if system_folder
|
if system_folder
|
||||||
l.project_id = system_folder.project_id
|
l.project_id = system_folder.project_id
|
||||||
l.dmsf_folder_id = system_folder.id
|
l.dmsf_folder_id = system_folder.id
|
||||||
if l.save
|
if l.save && (!@new_object)
|
||||||
issue.dmsf_file_added file
|
issue.dmsf_file_added file
|
||||||
end
|
end
|
||||||
wf = issue.saved_dmsf_links_wfs[l.id]
|
wf = issue.saved_dmsf_links_wfs[l.id]
|
||||||
|
|||||||
@ -147,15 +147,11 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dmsf_file_added(dmsf_file)
|
def dmsf_file_added(dmsf_file)
|
||||||
unless dmsf_file.new_record?
|
self.journalize_dmsf_file dmsf_file, :added
|
||||||
self.journalize_dmsf_file(dmsf_file, :added)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def dmsf_file_removed(dmsf_file)
|
def dmsf_file_removed(dmsf_file)
|
||||||
unless dmsf_file.new_record?
|
self.journalize_dmsf_file dmsf_file, :removed
|
||||||
self.journalize_dmsf_file(dmsf_file, :removed)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a journal detail for an attachment that was added or removed
|
# Adds a journal detail for an attachment that was added or removed
|
||||||
|
|||||||
@ -50,7 +50,8 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
DmsfUploadHelper.commit_files_internal uploaded_files, easy_crm_case.project, system_folder, self
|
DmsfUploadHelper.commit_files_internal uploaded_files, easy_crm_case.project, system_folder, self,
|
||||||
|
false, easy_crm_case
|
||||||
end
|
end
|
||||||
# Attach DMS links
|
# Attach DMS links
|
||||||
easy_crm_case.saved_dmsf_links.each do |l|
|
easy_crm_case.saved_dmsf_links.each do |l|
|
||||||
|
|||||||
@ -150,21 +150,17 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dmsf_file_added(dmsf_file)
|
def dmsf_file_added(dmsf_file)
|
||||||
unless dmsf_file.new_record?
|
self.journalize_dmsf_file dmsf_file, :added
|
||||||
self.journalize_dmsf_file(dmsf_file, :added)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def dmsf_file_removed(dmsf_file)
|
def dmsf_file_removed(dmsf_file)
|
||||||
unless dmsf_file.new_record?
|
self.journalize_dmsf_file dmsf_file, :removed
|
||||||
self.journalize_dmsf_file(dmsf_file, :removed)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a journal detail for an attachment that was added or removed
|
# Adds a journal detail for an attachment that was added or removed
|
||||||
def journalize_dmsf_file(dmsf_file, added_or_removed)
|
def journalize_dmsf_file(dmsf_file, added_or_removed)
|
||||||
key = (added_or_removed == :removed ? :old_value : :value)
|
key = (added_or_removed == :removed ? :old_value : :value)
|
||||||
init_journal(User.current)
|
init_journal User.current
|
||||||
current_journal.details << JournalDetail.new(
|
current_journal.details << JournalDetail.new(
|
||||||
property: 'dmsf_file',
|
property: 'dmsf_file',
|
||||||
prop_key: dmsf_file.id,
|
prop_key: dmsf_file.id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user