Project

General

Profile

Defect #5933 » news.patch

Yuki Kita, 2010-07-30 16:35

View differences:

app/controllers/news_controller.rb (working copy)
26 26
  accept_key_auth :index
27 27
  
28 28
  def index
29
    @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
29 30
    @news_pages, @newss = paginate :news,
30 31
                                   :per_page => 10,
31
                                   :conditions => Project.allowed_to_condition(User.current, :view_news, :project => @project),
32
                                   :conditions => Project.allowed_to_condition(User.current, :view_news, :project => @project, :with_subprojects => @with_subprojects),
32 33
                                   :include => [:author, :project],
33 34
                                   :order => "#{News.table_name}.created_on DESC"    
34 35
    respond_to do |format|
app/controllers/projects_controller.rb (working copy)
143 143
    
144 144
    @users_by_role = @project.users_by_role
145 145
    @subprojects = @project.children.visible
146
    @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
146
    @news = News.all(:conditions => Project.allowed_to_condition(User.current, :view_news, :project => @project,
147
                                                                 :with_subprojects => Setting.display_subprojects_issues?),
148
                     :include => [:author, :project],
149
                     :order => "#{News.table_name}.created_on DESC")
147 150
    @trackers = @project.rolled_up_trackers
148 151
    
149 152
    cond = @project.project_condition(Setting.display_subprojects_issues?)
app/views/news/_news.rhtml (working copy)
1
<p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %>
1
<p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %>
2 2
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
3 3
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
4 4
<br />
app/views/news/index.rhtml (working copy)
43 43
	<%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %>
44 44
<% end %>
45 45

  
46
<% content_for :sidebar do %>
47
  <% form_tag({:project_id => @project}, :method => :get) do %>
48
    <h3><%= l(:label_news) %></h3>
49
    <%= hidden_field_tag 'with_subprojects', 0 %>
50
    <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
51
    <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
52
  <% end %>
53
<% end if @project && @project.descendants.active.any? %>
54

  
46 55
<% content_for :header_tags do %>
47 56
  <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
48 57
<% end %>
(3-3/4)