diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 43d35cf..0d83d81 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index d88269f..47e6913 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -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)}, diff --git a/app/models/project.rb b/app/models/project.rb index 9e4bd69..adc70c6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/views/settings/_general.rhtml b/app/views/settings/_general.rhtml index 1d17a00..bb56c43 100644 --- a/app/views/settings/_general.rhtml +++ b/app/views/settings/_general.rhtml @@ -46,9 +46,6 @@

<%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %>

- -

-<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %>

<%= submit_tag l(:button_save) %> diff --git a/app/views/settings/_projects.rhtml b/app/views/settings/_projects.rhtml new file mode 100644 index 0000000..1cd4f6e --- /dev/null +++ b/app/views/settings/_projects.rhtml @@ -0,0 +1,12 @@ +<% form_tag({:action => 'edit', :tab => 'projects'}) do %> + +
+

+<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %>

+ +

+<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %>

+
+ +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/config/settings.yml b/config/settings.yml index ac79edb..e1ad341 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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: diff --git a/lang/bg.yml b/lang/bg.yml index 1f174e2..ddc3368 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -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 diff --git a/lang/cs.yml b/lang/cs.yml index 609e954..767fcdb 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -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 diff --git a/lang/da.yml b/lang/da.yml index a76e7ea..8f8905f 100644 --- a/lang/da.yml +++ b/lang/da.yml @@ -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 diff --git a/lang/de.yml b/lang/de.yml index e309dfb..1f6c629 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -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 diff --git a/lang/en.yml b/lang/en.yml index 5f55277..c9dddf9 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -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 diff --git a/lang/es.yml b/lang/es.yml index fc9540a..e4b4f06 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -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 diff --git a/lang/fi.yml b/lang/fi.yml index 6eb16bf..3ec7a6b 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -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 diff --git a/lang/fr.yml b/lang/fr.yml index 81e4494..f40a3f3 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -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é diff --git a/lang/he.yml b/lang/he.yml index 77fe32e..e89e65c 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -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 diff --git a/lang/hu.yml b/lang/hu.yml index 208b6fe..f8bfb93 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -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 diff --git a/lang/it.yml b/lang/it.yml index d123e91..e1ef6f8 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -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 diff --git a/lang/ja.yml b/lang/ja.yml index 5a728fb..dda73dc 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -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 diff --git a/lang/ko.yml b/lang/ko.yml index 16bd653..be7eab1 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -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 diff --git a/lang/lt.yml b/lang/lt.yml index 2a75a95..da581d6 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -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 diff --git a/lang/nl.yml b/lang/nl.yml index f79e789..b1c5756 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -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 diff --git a/lang/no.yml b/lang/no.yml index 6643f9c..7113b41 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -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 diff --git a/lang/pl.yml b/lang/pl.yml index 2df921b..e9ffcda 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -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 diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 8cd171b..b4064bf 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -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 diff --git a/lang/pt.yml b/lang/pt.yml index 5562ca4..1d4d043 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -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 diff --git a/lang/ro.yml b/lang/ro.yml index 5bb49ec..acb5ff8 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -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 diff --git a/lang/ru.yml b/lang/ru.yml index 01cdcd4..b0e137a 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -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 diff --git a/lang/sr.yml b/lang/sr.yml index 566a46d..4e26236 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -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 diff --git a/lang/sv.yml b/lang/sv.yml index 4cb1f07..3bb337e 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -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 diff --git a/lang/th.yml b/lang/th.yml index 2c3977d..a970871 100644 --- a/lang/th.yml +++ b/lang/th.yml @@ -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 diff --git a/lang/uk.yml b/lang/uk.yml index 7ba1524..cb4e173 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -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 diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index 6a14413..b91bef8 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -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 diff --git a/lang/zh.yml b/lang/zh.yml index bfe5510..dbc5311 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -637,3 +637,4 @@ enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) button_quote: Quote +setting_sequential_project_identifiers: Generate sequential project identifiers diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 91fab82..6e32c02 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -130,4 +130,15 @@ class ProjectTest < Test::Unit::TestCase assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) end + + def test_next_identifier + ProjectCustomField.delete_all + Project.create!(:name => 'last', :identifier => 'p2008040') + assert_equal 'p2008041', Project.next_identifier + end + + def test_next_identifier_first_project + Project.delete_all + assert_nil Project.next_identifier + end end