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:
parent
d5b9dedca2
commit
df99d8f308
|
@ -52,12 +52,11 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
attr_protected :status, :enabled_module_names
|
attr_protected :status, :enabled_module_names
|
||||||
|
|
||||||
validates_presence_of :name, :description, :identifier
|
validates_presence_of :name, :identifier
|
||||||
validates_uniqueness_of :name, :identifier
|
validates_uniqueness_of :name, :identifier
|
||||||
validates_associated :custom_values, :on => :update
|
validates_associated :custom_values, :on => :update
|
||||||
validates_associated :repository, :wiki
|
validates_associated :repository, :wiki
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_length_of :description, :maximum => 255
|
|
||||||
validates_length_of :homepage, :maximum => 60
|
validates_length_of :homepage, :maximum => 60
|
||||||
validates_length_of :identifier, :in => 3..20
|
validates_length_of :identifier, :in => 3..20
|
||||||
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
||||||
|
@ -184,6 +183,15 @@ class Project < ActiveRecord::Base
|
||||||
name.downcase <=> project.name.downcase
|
name.downcase <=> project.name.downcase
|
||||||
end
|
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)
|
def allows_to?(action)
|
||||||
if action.is_a? Hash
|
if action.is_a? Hash
|
||||||
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<% for project in @projects %>
|
<% for project in @projects %>
|
||||||
<tr class="<%= cycle("odd", "even") %>">
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
<td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %>
|
<td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %>
|
||||||
<td><%= textilizable project.description, :project => project %>
|
<td><%= textilizable project.short_description, :project => project %>
|
||||||
<td align="center"><%= image_tag 'true.png' if project.is_public? %>
|
<td align="center"><%= image_tag 'true.png' if project.is_public? %>
|
||||||
<td align="center"><%= project.children.size %>
|
<td align="center"><%= project.children.size %>
|
||||||
<td align="center"><%= format_date(project.created_on) %>
|
<td align="center"><%= format_date(project.created_on) %>
|
||||||
|
|
|
@ -8,8 +8,11 @@
|
||||||
<p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p>
|
<p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 5 %><em><%= l(:text_caracters_maximum, 255) %></em></p>
|
<p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p>
|
||||||
<p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_length_between, 3, 20) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p>
|
<p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %>
|
||||||
|
<% unless @project.identifier_frozen? %>
|
||||||
|
<br /><em><%= l(:text_length_between, 3, 20) %> <%= l(:text_project_identifier_info) %></em>
|
||||||
|
<% end %></p>
|
||||||
<p><%= f.text_field :homepage, :size => 40 %></p>
|
<p><%= f.text_field :homepage, :size => 40 %></p>
|
||||||
<p><%= f.check_box :is_public %></p>
|
<p><%= f.check_box :is_public %></p>
|
||||||
<%= wikitoolbar_for 'project_description' %>
|
<%= wikitoolbar_for 'project_description' %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<% @project_tree.keys.sort.each do |project| %>
|
<% @project_tree.keys.sort.each do |project| %>
|
||||||
<h3><%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %></h3>
|
<h3><%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %></h3>
|
||||||
<%= textilizable(project.description, :project => project) %>
|
<%= textilizable(project.short_description, :project => project) %>
|
||||||
|
|
||||||
<% if @project_tree[project].any? %>
|
<% if @project_tree[project].any? %>
|
||||||
<p><%= l(:label_subproject_plural) %>:
|
<p><%= l(:label_subproject_plural) %>:
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<% for project in @projects %>
|
<% for project in @projects %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
|
<%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
|
||||||
<%= textilizable project.description, :project => project %>
|
<%= textilizable project.short_description, :project => project %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class ChangeProjectsDescriptionToText < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
change_column :projects, :description, :text, :default => ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue