From 92a23c05bb71e62426cec2298d90b39fadd0eb52 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 3 Dec 2007 10:28:08 +0000 Subject: [PATCH] Project name format limitation removed (name can now contain any character). Project identifier maximum length changed from 12 to 20. git-svn-id: http://redmine.rubyforge.org/svn/trunk@949 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 8 ++++++-- app/helpers/queries_helper.rb | 2 +- app/models/project.rb | 3 +-- app/views/admin/projects.rhtml | 2 +- app/views/issues/_list_simple.rhtml | 2 +- app/views/layouts/_project_selector.rhtml | 4 ++-- app/views/my/account.rhtml | 2 +- app/views/projects/_form.rhtml | 2 +- app/views/projects/destroy.rhtml | 2 +- app/views/projects/gantt.rhtml | 4 ++-- app/views/projects/list.rhtml | 4 ++-- app/views/projects/show.rhtml | 4 ++-- lib/tasks/migrate_from_mantis.rake | 4 ++-- public/themes/alternate/stylesheets/application.css | 1 + test/functional/projects_controller_test.rb | 9 ++++++++- 15 files changed, 32 insertions(+), 21 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 37a78869..658e9d23 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -58,7 +58,9 @@ class ProjectsController < ApplicationController def add @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @trackers = Tracker.all - @root_projects = Project.find(:all, :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}") + @root_projects = Project.find(:all, + :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", + :order => 'name') @project = Project.new(params[:project]) @project.enabled_module_names = Redmine::AccessControl.available_project_modules if request.get? @@ -90,7 +92,9 @@ class ProjectsController < ApplicationController end def settings - @root_projects = Project::find(:all, :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id]) + @root_projects = Project.find(:all, + :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], + :order => 'name') @custom_fields = IssueCustomField.find(:all) @issue_category ||= IssueCategory.new @member ||= @project.members.new diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index f9278727..3011d3ae 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -38,7 +38,7 @@ module QueriesHelper else case column.name when :subject - ((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') + + h((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') + link_to(h(value), :controller => 'issues', :action => 'show', :id => issue) when :done_ratio progress_bar(value, :width => '80px') diff --git a/app/models/project.rb b/app/models/project.rb index 03ada035..5788732d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -57,10 +57,9 @@ class Project < ActiveRecord::Base validates_associated :custom_values, :on => :update validates_associated :repository, :wiki validates_length_of :name, :maximum => 30 - validates_format_of :name, :with => /^[\w\s\'\-]*$/i validates_length_of :description, :maximum => 255 validates_length_of :homepage, :maximum => 60 - validates_length_of :identifier, :in => 3..12 + validates_length_of :identifier, :in => 3..20 validates_format_of :identifier, :with => /^[a-z0-9\-]*$/ def identifier=(identifier) diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml index d231be10..423d56eb 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.rhtml @@ -26,7 +26,7 @@ <% for project in @projects %> "> - <%= project.active? ? link_to(project.name, :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %> + <%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %> <%= textilizable project.description, :project => project %> <%= image_tag 'true.png' if project.is_public? %> <%= project.children.size %> diff --git a/app/views/issues/_list_simple.rhtml b/app/views/issues/_list_simple.rhtml index 517055e3..eb93f8ea 100644 --- a/app/views/issues/_list_simple.rhtml +++ b/app/views/issues/_list_simple.rhtml @@ -11,7 +11,7 @@ <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %> - <%= issue.project.name %> - <%= issue.tracker.name %>
+ <%=h issue.project.name %> - <%= issue.tracker.name %>
<%= issue.status.name %> - <%= format_time(issue.updated_on) %> <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %> diff --git a/app/views/layouts/_project_selector.rhtml b/app/views/layouts/_project_selector.rhtml index 499879c8..ce2f15e0 100644 --- a/app/views/layouts/_project_selector.rhtml +++ b/app/views/layouts/_project_selector.rhtml @@ -3,10 +3,10 @@ <% user_projects_by_root.keys.sort.each do |root| %> - <%= content_tag('option', root.name, :value => url_for(:controller => 'projects', :action => 'show', :id => root)) %> + <%= content_tag('option', h(root.name), :value => url_for(:controller => 'projects', :action => 'show', :id => root)) %> <% user_projects_by_root[root].sort.each do |project| %> <% next if project == root %> - <%= content_tag('option', ('» ' + project.name), :value => url_for(:controller => 'projects', :action => 'show', :id => project)) %> + <%= content_tag('option', ('» ' + h(project.name)), :value => url_for(:controller => 'projects', :action => 'show', :id => project)) %> <% end %> <% end %> diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml index e6405177..2dda62d7 100644 --- a/app/views/my/account.rhtml +++ b/app/views/my/account.rhtml @@ -29,7 +29,7 @@ :onchange => 'if ($("notification_option").value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %> <% content_tag 'div', :id => 'notified-projects', :style => (@notification_option == 'selected' ? '' : 'display:none;') do %>

<% User.current.projects.each do |project| %> -
+
<% end %>

<%= l(:text_user_mail_option) %>

<% end %> diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 885ccf4b..e29777af 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -9,7 +9,7 @@ <% end %>

<%= f.text_area :description, :required => true, :cols => 60, :rows => 5 %><%= l(:text_caracters_maximum, 255) %>

-

<%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %>
<%= l(:text_length_between, 3, 12) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %>

+

<%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %>
<%= l(:text_length_between, 3, 20) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %>

<%= f.text_field :homepage, :size => 40 %>

<%= f.check_box :is_public %>

<%= wikitoolbar_for 'project_description' %> diff --git a/app/views/projects/destroy.rhtml b/app/views/projects/destroy.rhtml index 8ef23197..4531cb84 100644 --- a/app/views/projects/destroy.rhtml +++ b/app/views/projects/destroy.rhtml @@ -1,7 +1,7 @@

<%=l(:label_confirmation)%>

-

<%= @project_to_destroy.name %>
+

<%=h @project_to_destroy.name %>
<%=l(:text_project_destroy_confirmation)%>

diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml index 21ef600a..a6675484 100644 --- a/app/views/projects/gantt.rhtml +++ b/app/views/projects/gantt.rhtml @@ -72,8 +72,8 @@ top = headers_height + 8 @events.each do |i| %>

<% if i.is_a? Issue %> - <%= link_to_issue i %><%= " (#{i.project.name})" unless @project && @project == i.project %>: - <%=h i.subject %> + <%= h("#{i.project.name} -") unless @project && @project == i.project %> + <%= link_to_issue i %>: <%=h i.subject %> <% else %> <%= link_to_version i, :class => "icon icon-package" %> <% end %> diff --git a/app/views/projects/list.rhtml b/app/views/projects/list.rhtml index 51c1b544..c6e5b4de 100644 --- a/app/views/projects/list.rhtml +++ b/app/views/projects/list.rhtml @@ -1,13 +1,13 @@

<%=l(:label_project_plural)%>

<% @project_tree.keys.sort.each do |project| %> -

<%= link_to project.name, {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %>

+

<%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %>

<%= textilizable(project.description, :project => project) %> <% if @project_tree[project].any? %>

<%= l(:label_subproject_plural) %>: <%= @project_tree[project].sort.collect {|subproject| - link_to(subproject.name, {:action => 'show', :id => subproject}, :class => (User.current.member_of?(subproject) ? "icon icon-fav" : ""))}.join(', ') %>

+ link_to(h(subproject.name), {:action => 'show', :id => subproject}, :class => (User.current.member_of?(subproject) ? "icon icon-fav" : ""))}.join(', ') %>

<% end %> <% end %> diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index 458e7975..bb01df1f 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -5,10 +5,10 @@
    <% unless @project.homepage.blank? %>
  • <%=l(:field_homepage)%>: <%= auto_link @project.homepage %>
  • <% end %> <% if @subprojects.any? %> -
  • <%=l(:label_subproject_plural)%>: <%= @subprojects.collect{|p| link_to(p.name, :action => 'show', :id => p)}.join(", ") %>
  • +
  • <%=l(:label_subproject_plural)%>: <%= @subprojects.collect{|p| link_to(h(p.name), :action => 'show', :id => p)}.join(", ") %>
  • <% end %> <% if @project.parent %> -
  • <%=l(:field_parent)%>: <%= link_to @project.parent.name, :controller => 'projects', :action => 'show', :id => @project.parent %>
  • +
  • <%=l(:field_parent)%>: <%= link_to h(@project.parent.name), :controller => 'projects', :action => 'show', :id => @project.parent %>
  • <% end %> <% for custom_value in @custom_values %> <% if !custom_value.value.empty? %> diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake index 593d59d8..6d8d55e7 100644 --- a/lib/tasks/migrate_from_mantis.rake +++ b/lib/tasks/migrate_from_mantis.rake @@ -115,7 +115,7 @@ task :migrate_from_mantis => :environment do has_many :members, :class_name => "MantisProjectUser", :foreign_key => :project_id def name - read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-') + read_attribute(:name)[0..29] end def description @@ -123,7 +123,7 @@ task :migrate_from_mantis => :environment do end def identifier - read_attribute(:name).underscore[0..11].gsub(/[^a-z0-9\-]/, '-') + read_attribute(:name).underscore[0..19].gsub(/[^a-z0-9\-]/, '-') end end diff --git a/public/themes/alternate/stylesheets/application.css b/public/themes/alternate/stylesheets/application.css index ced63a41..af787ae7 100644 --- a/public/themes/alternate/stylesheets/application.css +++ b/public/themes/alternate/stylesheets/application.css @@ -63,6 +63,7 @@ input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hove input[type="text"], textarea, select { padding: 2px; border: 1px solid #d7d7d7; } input[type="text"] { padding: 3px; } input[type="text"]:focus, textarea:focus, select:focus { border: 1px solid #888866; } +option { border-bottom: 1px dotted #d7d7d7; } /* Misc */ .box { background-color: #fcfcfc; } diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index a48fa26b..d98e0d97 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -103,9 +103,16 @@ class ProjectsControllerTest < Test::Unit::TestCase } } } + + get :activity, :id => 1, :year => 3.days.ago.to_date.year, :month => 3.days.ago.to_date.month + assert_response :success + assert_template 'activity' + assert_not_nil assigns(:events_by_day) + assert_tag :tag => "h3", :content => /#{3.day.ago.to_date.day}/, - :sibling => { :tag => "ul", :child => { :tag => "li", + :sibling => { :tag => "ul", + :child => { :tag => "li", :child => { :tag => "p", :content => /#{Issue.find(1).subject}/, }