Set @project so macros will work on the welcome and project list. #5781

Contributed by Holger Just

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3824 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-06-30 03:32:18 +00:00
parent 43bbda1966
commit 64d2221db5
2 changed files with 6 additions and 0 deletions

View File

@ -56,7 +56,10 @@ module ProjectsHelper
s = '' s = ''
if projects.any? if projects.any?
ancestors = [] ancestors = []
original_project = @project
projects.each do |project| projects.each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
else else
@ -75,6 +78,7 @@ module ProjectsHelper
ancestors << project ancestors << project
end end
s << ("</li></ul>\n" * ancestors.size) s << ("</li></ul>\n" * ancestors.size)
@project = original_project
end end
s s
end end

View File

@ -18,11 +18,13 @@
<h3><%=l(:label_project_latest)%></h3> <h3><%=l(:label_project_latest)%></h3>
<ul> <ul>
<% for project in @projects %> <% for project in @projects %>
<% @project = project %>
<li> <li>
<%= link_to h(project.name), :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>) <%= link_to h(project.name), :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
<%= textilizable project.short_description, :project => project %> <%= textilizable project.short_description, :project => project %>
</li> </li>
<% end %> <% end %>
<% @project = nil %>
</ul> </ul>
</div> </div>
<% end %> <% end %>