]> source.dussan.org Git - redmine.git/commitdiff
Adds an option to generate sequential project identifiers.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 31 Aug 2008 12:59:57 +0000 (12:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 31 Aug 2008 12:59:57 +0000 (12:59 +0000)
Disabled by default, it can be enabled on the 'Projects' tab in application settings.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1777 e93f8b46-1217-0410-a6f0-8f06a7374b81

34 files changed:
app/controllers/projects_controller.rb
app/helpers/settings_helper.rb
app/models/project.rb
app/views/settings/_general.rhtml
app/views/settings/_projects.rhtml [new file with mode: 0644]
config/settings.yml
lang/bg.yml
lang/cs.yml
lang/da.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fi.yml
lang/fr.yml
lang/he.yml
lang/hu.yml
lang/it.yml
lang/ja.yml
lang/ko.yml
lang/lt.yml
lang/nl.yml
lang/no.yml
lang/pl.yml
lang/pt-br.yml
lang/pt.yml
lang/ro.yml
lang/ru.yml
lang/sr.yml
lang/sv.yml
lang/th.yml
lang/uk.yml
lang/zh-tw.yml
lang/zh.yml
test/unit/project_test.rb

index 43d35cf4fedd590f9b3d35f3a712bade6f9c87fe..0d83d81b3a03ba52a8974f3956f758e8704aa7b0 100644 (file)
@@ -69,6 +69,7 @@ class ProjectsController < ApplicationController
                                   :order => 'name')
     @project = Project.new(params[:project])
     if request.get?
+      @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
       @project.trackers = Tracker.all
       @project.is_public = Setting.default_projects_public?
       @project.enabled_module_names = Redmine::AccessControl.available_project_modules
index d88269f7d5bf17583cb8555ac5a6db08e2d93431..47e6913341fbb71ec30fbb31d3a507da8a31fd08 100644 (file)
@@ -19,6 +19,7 @@ module SettingsHelper
   def administration_settings_tabs
     tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
             {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
+            {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
             {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
             {:name => 'notifications', :partial => 'settings/notifications', :label => l(:field_mail_notification)},
             {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => l(:label_incoming_emails)},
index 9e4bd6971c631668a4d9aa41a68de070119220ce..adc70c644984df8009a73ca01ece416f03ee5932 100644 (file)
@@ -238,6 +238,12 @@ class Project < ActiveRecord::Base
       enabled_modules << EnabledModule.new(:name => name.to_s)
     end
   end
+  
+  # Returns an auto-generated project identifier based on the last identifier used
+  def self.next_identifier
+    p = Project.find(:first, :order => 'created_on DESC')
+    p.nil? ? nil : p.identifier.to_s.succ
+  end
 
 protected
   def validate
index 1d17a003e7c6b60e174aee5da137cd634b67e2b0..bb56c43dbcf916ed55cbd39679ac54ba4d58e567 100644 (file)
@@ -46,9 +46,6 @@
 
 <p><label><%= l(:setting_feeds_limit) %></label>
 <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
-
-<p><label><%= l(:setting_default_projects_public) %></label>
-<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p>
 </div>
 
 <%= submit_tag l(:button_save) %>
diff --git a/app/views/settings/_projects.rhtml b/app/views/settings/_projects.rhtml
new file mode 100644 (file)
index 0000000..1cd4f6e
--- /dev/null
@@ -0,0 +1,12 @@
+<% form_tag({:action => 'edit', :tab => 'projects'}) do %>
+
+<div class="box tabular settings">
+<p><label><%= l(:setting_default_projects_public) %></label>
+<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p>
+
+<p><label><%= l(:setting_sequential_project_identifiers) %></label>
+<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p>
+</div>
+
+<%= submit_tag l(:button_save) %>
+<% end %>
index ac79edb8da9a3d75b34ed4ddc29e35fc9e8cd99a..e1ad341def107e36420bd7ae9160fd8a9d4962b3 100644 (file)
@@ -118,6 +118,8 @@ display_subprojects_issues:
   default: 1
 default_projects_public:
   default: 1
+sequential_project_identifiers:
+  default: 0
 # encodings used to convert repository files content to UTF-8
 # multiple values accepted, comma separated
 repositories_encodings:
index 1f174e29fdd6fe0d2a7997cae77a1df674944da9..ddc3368efe6f2bc48caa1f2e8e391c98963f4e34 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 609e9547830f932f95803dabd992d15a3a0b01f1..767fcdbde874bf43aa328d979a9e811353b3bee7 100644 (file)
@@ -641,3 +641,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index a76e7ea5c1155cd1ca1d14faf17c53487619d49a..8f8905f32ffd54269b2dac721717738b426ff967 100644 (file)
@@ -638,3 +638,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index e309dfb576197f959a82362becc168096a8023bf..1f6c6291d392797b05bec462988dcdb0c4d8ed2a 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 5f552774cf533f61312d342c7bbf33652fb0706a..c9dddf9ccea665c8f7130222c2cedc70eb2921f6 100644 (file)
@@ -219,6 +219,7 @@ setting_display_subprojects_issues: Display subprojects issues on main projects
 setting_enabled_scm: Enabled SCM
 setting_mail_handler_api_enabled: Enable WS for incoming emails
 setting_mail_handler_api_key: API key
+setting_sequential_project_identifiers: Generate sequential project identifiers
 
 project_module_issue_tracking: Issue tracking
 project_module_time_tracking: Time tracking
index fc9540a02e5de1cbb7dc78cbed9259c731fdfb83..e4b4f06680efb41d1c2cd08c3a6726fbceb16600 100644 (file)
@@ -639,3 +639,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 6eb16bfacaa9bf498ff5e9600f16a3b3bb11c173..3ec7a6b501c04949488c6c763b9a6b19ac19a25d 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 81e44949f945920f2dbd61f30ba454351de8700c..f40a3f3d159cf068e1b277004da1b58ff778e84a 100644 (file)
@@ -220,6 +220,7 @@ setting_display_subprojects_issues: Afficher par défaut les demandes des sous-p
 setting_enabled_scm: SCM activés
 setting_mail_handler_api_enabled: "Activer le WS pour la réception d'emails"
 setting_mail_handler_api_key: Clé de protection de l'API
+setting_sequential_project_identifiers: Générer des identifiants de projet séquentiels
 
 project_module_issue_tracking: Suivi des demandes
 project_module_time_tracking: Suivi du temps passé
index 77fe32e53e8aaa060a922ec93d012ac102227c7d..e89e65c6120497826c79652a2f8e01dcb551f9c2 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 208b6fe1e1123572978eae57ed846af0a7ac2711..f8bfb93e8e38abdb08cde62c792626b88529753a 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index d123e913a0a2c9978c161a2f2c667f2a3df7967c..e1ef6f8fede27eb4923d7174a587484af8e16651 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 5a728fb02c7850d97ae4c8776a5e07f64ec3cafe..dda73dc2680ed02490e5359c3ba82a026a5fe844 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 16bd6536462c24c262bd3567aca9432bfd85ff4a..be7eab1fbf37ecebc5adbcbbd1a0d52218560a74 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 2a75a95ea8449ea02cdb7af57885e6dc5d308fbb..da581d6785e30d1da63345ffaeac0e0962c5845a 100644 (file)
@@ -639,3 +639,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index f79e78994ead2eb09ab1538b2ec3b0d20fd76489..b1c5756befefd8904fe9cddbbb45bd93ac8b6ef6 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 6643f9c86065a0952858d76331136127c76bd67a..7113b416a5274ff9c8c967c28a69db652a7e4d93 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 2df921b71f6ae89dada9a6101858661be06dd118..e9ffcda2cd84fefe4288eddd97b3603727f79b0f 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 8cd171b729606ceff78d1bc6f4ab359ac9c58ec7..b4064bf58c863913b8d99e407d4574361de369be 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers\r
 setting_commit_logs_encoding: Commit messages encoding\r
 button_quote: Quote\r
+setting_sequential_project_identifiers: Generate sequential project identifiers\r
index 5562ca4acd34a9b9f924206b53acbe322850f56c..1d4d043f5dab06766fc99ea96f24f6357dc789f6 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 5bb49ececec8bc5b158b3d5fe83659e0a73cec9a..acb5ff8ec6f6c46ee890ce2e4a16cb83d67132f8 100644 (file)
@@ -636,3 +636,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 01cdcd47854b6f66ed5c5e68d51970d0933ad7ed..b0e137aa93371d09521fcfd1404fa6af93c8e8f4 100644 (file)
@@ -640,3 +640,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 566a46d9fda088b5ff04c282b1eeffc038cb15c1..4e262369ee723257bce0b823d969bb27efd827a2 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 4cb1f073b54de2aa94a20eebab1dea24d544c64f..3bb337e3dcf0796afd74cc49718d1aaa3dc2750e 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 2c3977de2018b2cebc12c9b2d3333129b73332aa..a9708716ea79d8a74a0989f94570bb9cb42bd319 100644 (file)
@@ -639,3 +639,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 7ba15241352597d093048c781da31595c313ae31..cb4e17383087fae6cd5324d885b89ccab97910f3 100644 (file)
@@ -638,3 +638,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 6a144136452d97c9772941167c3fb5ab21ec3d0f..b91bef8f97097a5d17e35809962348841ce37beb 100644 (file)
@@ -637,3 +637,4 @@ field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index bfe5510931bee03be9c3e37e7666b951aa224fbf..dbc5311190a5865d322aacb39b52e25eaba6e3ca 100644 (file)
@@ -637,3 +637,4 @@ enumeration_issue_priorities: 问题优先级
 enumeration_doc_categories: 文档类别
 enumeration_activities: 活动(时间跟踪)
 button_quote: Quote
+setting_sequential_project_identifiers: Generate sequential project identifiers
index 91fab8208b770fefa849ba1e1afaaf90a7ee0d1f..6e32c02e7d357bed77655720222056e92e16f974 100644 (file)
@@ -130,4 +130,15 @@ class ProjectTest < Test::Unit::TestCase
     assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id)\r
     assert_equal [2, 3], child.rolled_up_trackers.collect(&:id)\r
   end\r
+  \r
+  def test_next_identifier\r
+    ProjectCustomField.delete_all\r
+    Project.create!(:name => 'last', :identifier => 'p2008040')\r
+    assert_equal 'p2008041', Project.next_identifier\r
+  end\r
+  \r
+  def test_next_identifier_first_project\r
+    Project.delete_all\r
+    assert_nil Project.next_identifier\r
+  end\r
 end\r