Unlimited and optional project description. The project list will show truncated descriptions only (the first fews lines).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1088 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-01-20 18:37:51 +00:00
parent d5b9dedca2
commit df99d8f308
6 changed files with 26 additions and 7 deletions
+10 -2
View File
@@ -52,12 +52,11 @@ class Project < ActiveRecord::Base
attr_protected :status, :enabled_module_names
validates_presence_of :name, :description, :identifier
validates_presence_of :name, :identifier
validates_uniqueness_of :name, :identifier
validates_associated :custom_values, :on => :update
validates_associated :repository, :wiki
validates_length_of :name, :maximum => 30
validates_length_of :description, :maximum => 255
validates_length_of :homepage, :maximum => 60
validates_length_of :identifier, :in => 3..20
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
@@ -184,6 +183,15 @@ class Project < ActiveRecord::Base
name.downcase <=> project.name.downcase
end
def to_s
name
end
# Returns a short description of the projects (first lines)
def short_description(length = 255)
description.gsub(/^(.{#{length}}[^\n]*).*$/m, '\1').strip if description
end
def allows_to?(action)
if action.is_a? Hash
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"