'Redmine like' error handling in macros
This commit is contained in:
parent
d4f4d4a37d
commit
292b91ca5e
@ -476,6 +476,8 @@ cs:
|
|||||||
notice_entries_copied: Kopírování se podařilo
|
notice_entries_copied: Kopírování se podařilo
|
||||||
notice_entries_moved: Přesun se podařil
|
notice_entries_moved: Přesun se podařil
|
||||||
label_dmsf_file_revision: DMS Dokument rev.
|
label_dmsf_file_revision: DMS Dokument rev.
|
||||||
|
error_not_supported_image_format: Nepodporovaný formát obrázku
|
||||||
|
error_not_supported_video_format: Nepodporovaný formát videa
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -471,6 +471,8 @@ de:
|
|||||||
notice_entries_copied: Kopieren ist gelungen
|
notice_entries_copied: Kopieren ist gelungen
|
||||||
notice_entries_moved: Verschiebung ist gelungen
|
notice_entries_moved: Verschiebung ist gelungen
|
||||||
label_dmsf_file_revision: DMS Dokument Rev.
|
label_dmsf_file_revision: DMS Dokument Rev.
|
||||||
|
error_not_supported_image_format: Nicht unterstütztes Bildformat
|
||||||
|
error_not_supported_video_format: Nicht unterstütztes Videoformat
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ en:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ es:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -454,6 +454,8 @@ fa:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -476,6 +476,8 @@ fr:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -476,6 +476,8 @@ hu:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ it: # Italian strings thx 2 Matteo Arceci!
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -477,6 +477,8 @@ ja:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ ko:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ nl:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -474,6 +474,8 @@ pl:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -475,6 +475,8 @@ pt-BR:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -476,6 +476,8 @@ sl:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -477,6 +477,8 @@ uk:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -474,6 +474,8 @@ zh-TW:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -476,6 +476,8 @@ zh:
|
|||||||
notice_entries_copied: Copying has succeeded
|
notice_entries_copied: Copying has succeeded
|
||||||
notice_entries_moved: Moving has succeeded
|
notice_entries_moved: Moving has succeeded
|
||||||
label_dmsf_file_revision: DMS Document rev.
|
label_dmsf_file_revision: DMS Document rev.
|
||||||
|
error_not_supported_image_format: Not supported image format
|
||||||
|
error_not_supported_video_format: Not supported video format
|
||||||
|
|
||||||
easy_pages:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@ -29,16 +29,17 @@ module RedmineDmsf
|
|||||||
macro :dmsf do |_obj, args|
|
macro :dmsf do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
|
return "{{dmsf(#{args[0]})}}" unless file
|
||||||
unless User.current&.allowed_to?(:view_dmsf_files, file.project, { id: file.id })
|
unless User.current&.allowed_to?(:view_dmsf_files, file.project, { id: file.id })
|
||||||
raise l(:notice_not_authorized)
|
raise ::I18n.t(:notice_not_authorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
if args[2].blank?
|
if args[2].blank?
|
||||||
revision = file.last_revision
|
revision = file.last_revision
|
||||||
else
|
else
|
||||||
revision = DmsfFileRevision.find_by(id: args[2], dmsf_file_id: args[0])
|
revision = DmsfFileRevision.find_by(id: args[2], dmsf_file_id: args[0])
|
||||||
raise ActiveRecord::RecordNotFound unless revision
|
return "{{dmsf(#{args[0]}, #{args[1]}, #{args[2]})}" unless revision
|
||||||
end
|
end
|
||||||
title = (args[1].presence || file.title)
|
title = (args[1].presence || file.title)
|
||||||
title.gsub!(/\A"|"\z/, '') # Remove apostrophes
|
title.gsub!(/\A"|"\z/, '') # Remove apostrophes
|
||||||
@ -60,13 +61,14 @@ module RedmineDmsf
|
|||||||
macro :dmsff do |_obj, args|
|
macro :dmsff do |_obj, args|
|
||||||
if args.empty?
|
if args.empty?
|
||||||
unless User.current.allowed_to?(:view_dmsf_folders, @project) && @project.module_enabled?(:dmsf)
|
unless User.current.allowed_to?(:view_dmsf_folders, @project) && @project.module_enabled?(:dmsf)
|
||||||
raise l(:notice_not_authorized)
|
raise ::I18n.t(:notice_not_authorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
return link_to l(:link_documents), dmsf_folder_url(@project)
|
return link_to ::I18n.t(:link_documents), dmsf_folder_url(@project)
|
||||||
else
|
else
|
||||||
folder = DmsfFolder.visible.find args[0]
|
folder = DmsfFolder.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_folders, folder&.project)
|
return "{{dmsff(#{args[0]})}}" unless folder
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_folders, folder.project)
|
||||||
|
|
||||||
title = (args[1].presence || folder.title)
|
title = (args[1].presence || folder.title)
|
||||||
title.gsub!(/\A"|"\z/, '') # Remove leading and trailing apostrophe
|
title.gsub!(/\A"|"\z/, '') # Remove leading and trailing apostrophe
|
||||||
@ -83,8 +85,9 @@ module RedmineDmsf
|
|||||||
macro :dmsfd do |_obj, args|
|
macro :dmsfd do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsfd(#{args[0]})}}" unless file
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
|
||||||
title = (args[1].presence || file.title)
|
title = (args[1].presence || file.title)
|
||||||
title.gsub!(/\A"|"\z/, '') # Remove leading and trailing apostrophe
|
title.gsub!(/\A"|"\z/, '') # Remove leading and trailing apostrophe
|
||||||
@ -99,8 +102,9 @@ module RedmineDmsf
|
|||||||
macro :dmsfdesc do |_obj, args|
|
macro :dmsfdesc do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsfdesc(#{args[0]})}}" unless file
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
|
||||||
textilizable file.description
|
textilizable file.description
|
||||||
end
|
end
|
||||||
@ -112,17 +116,17 @@ module RedmineDmsf
|
|||||||
macro :dmsfversion do |_obj, args|
|
macro :dmsfversion do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
|
return "{{dmsfversion(#{args[0]})}}" unless file
|
||||||
unless User.current&.allowed_to?(:view_dmsf_files, file.project, { id: file.id })
|
unless User.current&.allowed_to?(:view_dmsf_files, file.project, { id: file.id })
|
||||||
raise l(:notice_not_authorized)
|
raise ::I18n.t(:notice_not_authorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
if args[1].blank?
|
if args[1].blank?
|
||||||
revision = file.last_revision
|
revision = file.last_revision
|
||||||
else
|
else
|
||||||
revision = DmsfFileRevision.find_by(id: args[1], dmsf_file_id: args[0])
|
revision = DmsfFileRevision.find_by(id: args[1], dmsf_file_id: args[0])
|
||||||
raise ActiveRecord::RecordNotFound unless revision
|
return "{{dmsfversion(#{args[0]}, #{args[1]})}}" unless revision
|
||||||
|
|
||||||
end
|
end
|
||||||
textilizable revision.version
|
textilizable revision.version
|
||||||
end
|
end
|
||||||
@ -134,8 +138,9 @@ module RedmineDmsf
|
|||||||
macro :dmsflastupdate do |_obj, args|
|
macro :dmsflastupdate do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsflastupdate(#{args[0]})}}" unless file
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
|
||||||
textilizable format_time(file.last_revision.updated_at)
|
textilizable format_time(file.last_revision.updated_at)
|
||||||
end
|
end
|
||||||
@ -147,8 +152,9 @@ module RedmineDmsf
|
|||||||
macro :dmsft do |_obj, args|
|
macro :dmsft do |_obj, args|
|
||||||
raise ArgumentError if args.length < 2 # Requires file id and lines number
|
raise ArgumentError if args.length < 2 # Requires file id and lines number
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsft(#{args[0]}, #{args[1]})}}" unless file
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
|
||||||
content_tag :pre, file.text_preview(args[1])
|
content_tag :pre, file.text_preview(args[1])
|
||||||
end
|
end
|
||||||
@ -172,9 +178,13 @@ module RedmineDmsf
|
|||||||
ids = args[0].split
|
ids = args[0].split
|
||||||
html = []
|
html = []
|
||||||
ids.each do |id|
|
ids.each do |id|
|
||||||
file = DmsfFile.visible.find(id)
|
file = DmsfFile.visible.find_by(id: id)
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
unless file
|
||||||
raise 'Not supported image format' unless file.image?
|
html << "{{dmsf_image(#{args[0]})}}"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
raise ::I18n.t(:error_not_supported_image_format) unless file.image?
|
||||||
|
|
||||||
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
||||||
filename = file.last_revision.formatted_name(member)
|
filename = file.last_revision.formatted_name(member)
|
||||||
@ -207,9 +217,10 @@ module RedmineDmsf
|
|||||||
size = options[:size]
|
size = options[:size]
|
||||||
width = options[:width]
|
width = options[:width]
|
||||||
height = options[:height]
|
height = options[:height]
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsf_video(#{args[0]})}}" unless file
|
||||||
raise 'Not supported video format' unless file.video?
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
raise ::I18n.t(:error_not_supported_video_format) unless file.video?
|
||||||
|
|
||||||
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
||||||
filename = file.last_revision.formatted_name(member)
|
filename = file.last_revision.formatted_name(member)
|
||||||
@ -228,6 +239,7 @@ module RedmineDmsf
|
|||||||
# dmsftn - link to an image thumbnail
|
# dmsftn - link to an image thumbnail
|
||||||
desc %{Wiki DMSF thumbnail:
|
desc %{Wiki DMSF thumbnail:
|
||||||
{{dmsftn(file_id)}} -- with default height 200 (auto width)
|
{{dmsftn(file_id)}} -- with default height 200 (auto width)
|
||||||
|
{{dmsftn(file_id1 file_id2 file_id3)}} -- multiple thumbnails
|
||||||
{{dmsftn(file_id, size=300)}} -- with size 300x300
|
{{dmsftn(file_id, size=300)}} -- with size 300x300
|
||||||
{{dmsftn(file_id, height=300)}} -- with height (auto width)
|
{{dmsftn(file_id, height=300)}} -- with height (auto width)
|
||||||
{{dmsftn(file_id, width=300)}} -- with width (auto height)
|
{{dmsftn(file_id, width=300)}} -- with width (auto height)
|
||||||
@ -242,9 +254,13 @@ module RedmineDmsf
|
|||||||
ids = args[0].split
|
ids = args[0].split
|
||||||
html = []
|
html = []
|
||||||
ids.each do |id|
|
ids.each do |id|
|
||||||
file = DmsfFile.visible.find(id)
|
file = DmsfFile.visible.find_by(id: id)
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
unless file
|
||||||
raise 'Not supported image format' unless file.image?
|
html << "{{dmsftn(#{id})}}"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
raise ::I18n.t(:error_not_supported_image_format) unless file.image?
|
||||||
|
|
||||||
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
member = Member.find_by(user_id: User.current.id, project_id: file.project.id)
|
||||||
filename = file.last_revision.formatted_name(member)
|
filename = file.last_revision.formatted_name(member)
|
||||||
@ -274,9 +290,9 @@ module RedmineDmsf
|
|||||||
macro :dmsfw do |_obj, args|
|
macro :dmsfw do |_obj, args|
|
||||||
raise ArgumentError if args.empty? # Requires file id
|
raise ArgumentError if args.empty? # Requires file id
|
||||||
|
|
||||||
file = DmsfFile.visible.find args[0]
|
file = DmsfFile.visible.find_by(id: args[0])
|
||||||
raise l(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
return "{{dmsfw(#{args[0]})}}" unless file
|
||||||
raise ActiveRecord::RecordNotFound unless file.last_revision
|
raise ::I18n.t(:notice_not_authorized) unless User.current&.allowed_to?(:view_dmsf_files, file.project)
|
||||||
|
|
||||||
file.last_revision.workflow_str(false)
|
file.last_revision.workflow_str(false)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
|
|
||||||
def test_macro_dmsf_file_not_found
|
def test_macro_dmsf_file_not_found
|
||||||
text = textilizable('{{dmsf(99)}}')
|
text = textilizable('{{dmsf(99)}}')
|
||||||
assert text.include?('Error')
|
assert text.include?('{{dmsf(99)}}'), text
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_dmsf_no_permissions
|
def test_macro_dmsf_no_permissions
|
||||||
@ -283,7 +283,7 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
|
|
||||||
def test_macro_dmsf_image_not_image
|
def test_macro_dmsf_image_not_image
|
||||||
text = textilizable("{{dmsf_image(#{@file1.id})}}")
|
text = textilizable("{{dmsf_image(#{@file1.id})}}")
|
||||||
assert text.include?('Not supported image format')
|
assert text.include?(::I18n.t(:error_not_supported_image_format))
|
||||||
end
|
end
|
||||||
|
|
||||||
# {{dmsf_video(file_id)}}
|
# {{dmsf_video(file_id)}}
|
||||||
@ -336,7 +336,7 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
|
|
||||||
def test_macro_dmsf_video_not_video
|
def test_macro_dmsf_video_not_video
|
||||||
text = textilizable("{{dmsf_video(#{@file7.id})}}")
|
text = textilizable("{{dmsf_video(#{@file7.id})}}")
|
||||||
assert text.include?('Not supported video format'), text
|
assert text.include?(::I18n.t(:error_not_supported_video_format)), text
|
||||||
end
|
end
|
||||||
|
|
||||||
# {{dmsftn(file_id)}}
|
# {{dmsftn(file_id)}}
|
||||||
@ -429,7 +429,7 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
|
|
||||||
def test_macro_dmsftn_not_image
|
def test_macro_dmsftn_not_image
|
||||||
text = textilizable("{{dmsftn(#{@file1.id})}}")
|
text = textilizable("{{dmsftn(#{@file1.id})}}")
|
||||||
assert text.include?('Not supported image format')
|
assert text.include?(::I18n.t(:error_not_supported_image_format))
|
||||||
end
|
end
|
||||||
|
|
||||||
# {{dmsfw(file_id)}}
|
# {{dmsfw(file_id)}}
|
||||||
@ -441,12 +441,12 @@ class DmsfMacrosTest < RedmineDmsf::Test::HelperTest
|
|||||||
def test_macro_dmsfw_no_permissions
|
def test_macro_dmsfw_no_permissions
|
||||||
@manager_role.remove_permission! :view_dmsf_files
|
@manager_role.remove_permission! :view_dmsf_files
|
||||||
text = textilizable("{{dmsfw(#{@file1.id})}}")
|
text = textilizable("{{dmsfw(#{@file1.id})}}")
|
||||||
assert text.include?('Error'), text
|
assert text.include?(::I18n.t(:notice_not_authorized))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_macro_dmsfw_dmsf_off
|
def test_macro_dmsfw_dmsf_off
|
||||||
@project1.disable_module! :dmsf
|
@project1.disable_module! :dmsf
|
||||||
text = textilizable("{{dmsfw(#{@file1.id})}}")
|
text = textilizable("{{dmsfw(#{@file1.id})}}")
|
||||||
assert text.include?('Error'), text
|
assert text.include?(::I18n.t(:notice_not_authorized))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user