comparison app/models/board.rb @ 931:ec1c49528f36 cannam_integration

Merge from branch "redmine-1.3"
author Chris Cannam
date Wed, 27 Jun 2012 15:04:58 +0100
parents 5f33065ddc4b
children 433d4f72a19b
comparison
equal deleted inserted replaced
930:027cc0f5d4a2 931:ec1c49528f36
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 class Board < ActiveRecord::Base 18 class Board < ActiveRecord::Base
19 include Redmine::SafeAttributes
19 belongs_to :project 20 belongs_to :project
20 has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC" 21 has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
21 has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC" 22 has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
22 belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id 23 belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
23 acts_as_list :scope => :project_id 24 acts_as_list :scope => :project_id
27 validates_length_of :name, :maximum => 30 28 validates_length_of :name, :maximum => 30
28 validates_length_of :description, :maximum => 255 29 validates_length_of :description, :maximum => 255
29 30
30 named_scope :visible, lambda {|*args| { :include => :project, 31 named_scope :visible, lambda {|*args| { :include => :project,
31 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } 32 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
33
34 safe_attributes 'name', 'description', 'move_to'
32 35
33 def visible?(user=User.current) 36 def visible?(user=User.current)
34 !user.nil? && user.allowed_to?(:view_messages, project) 37 !user.nil? && user.allowed_to?(:view_messages, project)
35 end 38 end
36 39