Revision 1088
Added by Jean-Philippe Lang over 17 years ago
trunk/app/models/project.rb | ||
---|---|---|
52 | 52 |
|
53 | 53 |
attr_protected :status, :enabled_module_names |
54 | 54 |
|
55 |
validates_presence_of :name, :description, :identifier
|
|
55 |
validates_presence_of :name, :identifier |
|
56 | 56 |
validates_uniqueness_of :name, :identifier |
57 | 57 |
validates_associated :custom_values, :on => :update |
58 | 58 |
validates_associated :repository, :wiki |
59 | 59 |
validates_length_of :name, :maximum => 30 |
60 |
validates_length_of :description, :maximum => 255 |
|
61 | 60 |
validates_length_of :homepage, :maximum => 60 |
62 | 61 |
validates_length_of :identifier, :in => 3..20 |
63 | 62 |
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/ |
... | ... | |
184 | 183 |
name.downcase <=> project.name.downcase |
185 | 184 |
end |
186 | 185 |
|
186 |
def to_s |
|
187 |
name |
|
188 |
end |
|
189 |
|
|
190 |
# Returns a short description of the projects (first lines) |
|
191 |
def short_description(length = 255) |
|
192 |
description.gsub(/^(.{#{length}}[^\n]*).*$/m, '\1').strip if description |
|
193 |
end |
|
194 |
|
|
187 | 195 |
def allows_to?(action) |
188 | 196 |
if action.is_a? Hash |
189 | 197 |
allowed_actions.include? "#{action[:controller]}/#{action[:action]}" |
trunk/app/views/admin/projects.rhtml | ||
---|---|---|
27 | 27 |
<% for project in @projects %> |
28 | 28 |
<tr class="<%= cycle("odd", "even") %>"> |
29 | 29 |
<td><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %> |
30 |
<td><%= textilizable project.description, :project => project %> |
|
30 |
<td><%= textilizable project.short_description, :project => project %>
|
|
31 | 31 |
<td align="center"><%= image_tag 'true.png' if project.is_public? %> |
32 | 32 |
<td align="center"><%= project.children.size %> |
33 | 33 |
<td align="center"><%= format_date(project.created_on) %> |
trunk/app/views/projects/_form.rhtml | ||
---|---|---|
8 | 8 |
<p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p> |
9 | 9 |
<% end %> |
10 | 10 |
|
11 |
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 5 %><em><%= l(:text_caracters_maximum, 255) %></em></p> |
|
12 |
<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> |
|
11 |
<p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p> |
|
12 |
<p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %> |
|
13 |
<% unless @project.identifier_frozen? %> |
|
14 |
<br /><em><%= l(:text_length_between, 3, 20) %> <%= l(:text_project_identifier_info) %></em> |
|
15 |
<% end %></p> |
|
13 | 16 |
<p><%= f.text_field :homepage, :size => 40 %></p> |
14 | 17 |
<p><%= f.check_box :is_public %></p> |
15 | 18 |
<%= wikitoolbar_for 'project_description' %> |
trunk/app/views/projects/list.rhtml | ||
---|---|---|
2 | 2 |
|
3 | 3 |
<% @project_tree.keys.sort.each do |project| %> |
4 | 4 |
<h3><%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %></h3> |
5 |
<%= textilizable(project.description, :project => project) %> |
|
5 |
<%= textilizable(project.short_description, :project => project) %>
|
|
6 | 6 |
|
7 | 7 |
<% if @project_tree[project].any? %> |
8 | 8 |
<p><%= l(:label_subproject_plural) %>: |
trunk/app/views/welcome/index.rhtml | ||
---|---|---|
18 | 18 |
<% for project in @projects %> |
19 | 19 |
<li> |
20 | 20 |
<%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>) |
21 |
<%= textilizable project.description, :project => project %> |
|
21 |
<%= textilizable project.short_description, :project => project %>
|
|
22 | 22 |
</li> |
23 | 23 |
<% end %> |
24 | 24 |
</ul> |
trunk/db/migrate/087_change_projects_description_to_text.rb | ||
---|---|---|
1 |
class ChangeProjectsDescriptionToText < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
change_column :projects, :description, :text, :default => '' |
|
4 |
end |
|
5 |
|
|
6 |
def self.down |
|
7 |
end |
|
8 |
end |
|
0 | 9 |
Also available in: Unified diff
Unlimited and optional project description. The project list will show truncated descriptions only (the first fews lines).