mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Adds 'project' option to recent_pages macro in order to display recent pages from a specific project (#43372).
Patch by Florian Walchshofer (user:amiswalc). git-svn-id: https://svn.redmine.org/redmine/trunk@24235 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
11612e5174
commit
b8daf724f8
@ -224,14 +224,21 @@ module Redmine
|
||||
"{{recent_pages}} -- displays pages updated within the last 7 days\n" +
|
||||
"{{recent_pages(days=3)}} -- displays pages updated within the last 3 days\n" +
|
||||
"{{recent_pages(limit=5)}} -- limits the maximum number of pages to display to 5\n" +
|
||||
"{{recent_pages(time=true)}} -- displays pages updated within the last 7 days with updated time"
|
||||
"{{recent_pages(time=true)}} -- displays pages updated within the last 7 days with updated time\n" +
|
||||
"{{recent_pages(project=identifier)}} -- displays pages updated within the last 7 days from a specific project"
|
||||
|
||||
macro :recent_pages do |obj, args|
|
||||
project = current_project(obj)
|
||||
args, options = extract_macro_options(args, :days, :limit, :time, :project)
|
||||
|
||||
if options[:project].presence
|
||||
project = Project.find_by_identifier(options[:project].to_s) if options[:project].present?
|
||||
else
|
||||
project = current_project(obj)
|
||||
end
|
||||
|
||||
return '' if project.nil?
|
||||
return '' unless User.current.allowed_to?(:view_wiki_pages, project)
|
||||
|
||||
args, options = extract_macro_options(args, :days, :limit, :time)
|
||||
days_to_list = (options[:days].presence || 7).to_i
|
||||
limit = options[:limit].to_i if options[:limit].present?
|
||||
is_show_time = options[:time].to_s == 'true'
|
||||
|
||||
@ -617,4 +617,20 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_recent_pages_macro_with_project_option
|
||||
@project = Project.find(1)
|
||||
freeze_time do
|
||||
WikiContent.update_all(updated_on: Time.current)
|
||||
@project.wiki.pages.each_with_index do |page, i|
|
||||
page.content.update_attribute(:updated_on, (i + 1).days.ago)
|
||||
end
|
||||
with_settings :text_formatting => 'textile' do
|
||||
result = textilizable('{{recent_pages(time=true, days=3, project=' + @project.identifier + ')}}')
|
||||
assert_select_in result, 'ul>li', :count => 3
|
||||
assert_select_in result, 'ul>li:first-of-type', :text => 'Another page (1 day)'
|
||||
assert_select_in result, 'ul>li:last-of-type', :text => 'Child 1 1 (3 days)'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user