Easy compatibility

This commit is contained in:
1redmine 2025-06-12 15:22:47 +02:00
parent 6461ad37af
commit b16d50e65c
5 changed files with 21 additions and 22 deletions

View File

@ -628,9 +628,13 @@ class DmsfFile < ApplicationRecord
def container
return unless dmsf_folder&.system && dmsf_folder.title&.match(/(^\d+)/)
issue_id = Regexp.last_match(1)
parent = dmsf_folder.dmsf_folder
Regexp.last_match(1).constantize.visible.find_by(id: issue_id) if parent&.title&.match(/^\.(.+)s/)
id = Regexp.last_match(1).to_i
case dmsf_folder.dmsf_folder&.title
when '.CRM cases'
EasyCrmCase.visible.find_by id: id
when '.Issues'
Issue.visible.find_by id: id
end
end
if defined?(EasyExtensions)

View File

@ -71,12 +71,7 @@ module RedmineDmsf
def dmsf_webdav?
value = Setting.plugin_redmine_dmsf['dmsf_webdav']
webdav = value.to_i.positive? || value == 'true'
if webdav && defined?(EasyExtensions)
webdav = Redmine::Plugin.installed?('easy_hosting_services') &&
EasyHostingServices::EasyMultiTenancy.activated?
end
webdav
value.to_i.positive? || value == 'true'
end
def dmsf_display_notified_recipients?

View File

@ -196,18 +196,18 @@ module RedmineDmsf
end
end
def attachment_rows(links, issue, controller)
def attachment_rows(links, container, controller)
return unless links.any?
html = "<tbody><tr><th colspan=\"4\">#{l(:label_dmsf_attachments)} (#{links.count})</th></tr>"
links.each do |dmsf_file, link, _created_at|
html << attachment_row(dmsf_file, link, issue, controller)
html << attachment_row(dmsf_file, link, container, controller)
end
html << '</tbody>'
html
end
def attachment_row(dmsf_file, link, issue, controller)
def attachment_row(dmsf_file, link, container, controller)
html = link ? +'<tr class="dmsf-gray">' : +'<tr>'
# Checkbox
html << '<td></td>'
@ -273,13 +273,19 @@ module RedmineDmsf
title: l(:title_notifications_not_active_activate), class: 'icon icon-email-add'
end
# Delete
if issue.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation,
dmsf_file.project)) || (!link &&
if container.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation,
dmsf_file.project)) || (!link &&
User.current.allowed_to?(:file_delete, dmsf_file.project)))
back_url = case container.class.name
when 'Issue'
issue_path container
when 'EasyCrmCase'
easy_crm_case_path container
end
url = if link
dmsf_link_path link, commit: 'yes', back_url: issue_path(issue)
dmsf_link_path link, commit: 'yes', back_url: back_url
else
dmsf_file_path id: dmsf_file, commit: 'yes', back_url: issue_path(issue)
dmsf_file_path id: dmsf_file, commit: 'yes', back_url: back_url
end
html << delete_link(url)
end

View File

@ -237,9 +237,6 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
def test_show_webdav_disabled
post '/login', params: { username: 'jsmith', password: 'jsmith' }
# TODO: with_settings seems to be not working with Easy
return if defined?(EasyExtensions)
with_settings plugin_redmine_dmsf: { 'dmsf_webdav' => nil } do
get "/projects/#{@project1.id}/dmsf"
assert_response :success

View File

@ -44,9 +44,6 @@ class DmsfWebdavCustomMiddlewareTest < RedmineDmsf::Test::IntegrationTest
end
def test_webdav_not_enabled
# TODO: with_settings seems to be not working with Easy
return if defined?(EasyExtensions)
with_settings plugin_redmine_dmsf: { 'dmsf_webdav' => nil } do
process :options, '/dmsf/webdav'
assert_response :not_found