diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 5d83c1320..be2b44c06 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -74,10 +74,10 @@ class NewsController < ApplicationController @q = params[:subject] if params[:subject].nil? || params[:subject].blank? scope_order = scope.all(:include => [:author, :course], - :order => "#{News.table_name}.created_on DESC") + :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") else scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course], - :order => "#{News.table_name}.created_on DESC") + :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") end # :offset => @offset, diff --git a/app/models/news.rb b/app/models/news.rb index a9e9d1d18..e9b8b5314 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -66,7 +66,7 @@ class News < ActiveRecord::Base scope :course_visible, lambda {|*args| includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args)) } - safe_attributes 'title', 'summary', 'description' + safe_attributes 'title', 'summary', 'description', 'sticky' def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_news, project) diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 0a5488714..a51b85870 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -4,6 +4,10 @@
+