|
|
@@ -5,12 +5,12 @@ |
|
|
|
# modify it under the terms of the GNU General Public License |
|
|
|
# as published by the Free Software Foundation; either version 2 |
|
|
|
# of the License, or (at your option) any later version. |
|
|
|
# |
|
|
|
# |
|
|
|
# This program is distributed in the hope that it will be useful, |
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
# GNU General Public License for more details. |
|
|
|
# |
|
|
|
# |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with this program; if not, write to the Free Software |
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
|
@@ -25,9 +25,9 @@ class NewsController < ApplicationController |
|
|
|
before_filter :find_optional_project, :only => :index |
|
|
|
accept_rss_auth :index |
|
|
|
accept_api_auth :index |
|
|
|
|
|
|
|
|
|
|
|
helper :watchers |
|
|
|
|
|
|
|
|
|
|
|
def index |
|
|
|
case params[:format] |
|
|
|
when 'xml', 'json' |
|
|
@@ -35,9 +35,9 @@ class NewsController < ApplicationController |
|
|
|
else |
|
|
|
@limit = 10 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
scope = @project ? @project.news.visible : News.visible |
|
|
|
|
|
|
|
|
|
|
|
@news_count = scope.count |
|
|
|
@news_pages = Paginator.new self, @news_count, @limit, params['page'] |
|
|
|
@offset ||= @news_pages.current.offset |
|
|
@@ -45,14 +45,14 @@ class NewsController < ApplicationController |
|
|
|
:order => "#{News.table_name}.created_on DESC", |
|
|
|
:offset => @offset, |
|
|
|
:limit => @limit) |
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
format.html { render :layout => false if request.xhr? } |
|
|
|
format.api |
|
|
|
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def show |
|
|
|
@comments = @news.comments |
|
|
|
@comments.reverse! if User.current.wants_comments_in_reverse_order? |
|
|
@@ -77,7 +77,7 @@ class NewsController < ApplicationController |
|
|
|
|
|
|
|
def edit |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def update |
|
|
|
if request.put? and @news.update_attributes(params[:news]) |
|
|
|
flash[:notice] = l(:notice_successful_update) |
|
|
@@ -91,14 +91,14 @@ class NewsController < ApplicationController |
|
|
|
@news.destroy |
|
|
|
redirect_to :action => 'index', :project_id => @project |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
def find_project |
|
|
|
@project = Project.find(params[:project_id]) |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
render_404 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def find_optional_project |
|
|
|
return true unless params[:project_id] |
|
|
|
@project = Project.find(params[:project_id]) |