Browse Source

Adds an option to generate sequential project identifiers.

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
tags/0.8.0-RC1
Jean-Philippe Lang 15 years ago
parent
commit
dbad26c87d

+ 1
- 0
app/controllers/projects_controller.rb View 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

+ 1
- 0
app/helpers/settings_helper.rb View 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)},

+ 6
- 0
app/models/project.rb View 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

+ 0
- 3
app/views/settings/_general.rhtml View 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) %>

+ 12
- 0
app/views/settings/_projects.rhtml View File

@@ -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 %>

+ 2
- 0
config/settings.yml View 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:

+ 1
- 0
lang/bg.yml View 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

+ 1
- 0
lang/cs.yml View 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

+ 1
- 0
lang/da.yml View 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

+ 1
- 0
lang/de.yml View 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

+ 1
- 0
lang/en.yml View 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

+ 1
- 0
lang/es.yml View 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

+ 1
- 0
lang/fi.yml View 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

+ 1
- 0
lang/fr.yml View 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é

+ 1
- 0
lang/he.yml View 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

+ 1
- 0
lang/hu.yml View 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

+ 1
- 0
lang/it.yml View 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

+ 1
- 0
lang/ja.yml View 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

+ 1
- 0
lang/ko.yml View 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

+ 1
- 0
lang/lt.yml View 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

+ 1
- 0
lang/nl.yml View 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

+ 1
- 0
lang/no.yml View 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

+ 1
- 0
lang/pl.yml View 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

+ 1
- 0
lang/pt-br.yml View 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

+ 1
- 0
lang/pt.yml View 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

+ 1
- 0
lang/ro.yml View 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

+ 1
- 0
lang/ru.yml View 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

+ 1
- 0
lang/sr.yml View 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

+ 1
- 0
lang/sv.yml View 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

+ 1
- 0
lang/th.yml View 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

+ 1
- 0
lang/uk.yml View 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

+ 1
- 0
lang/zh-tw.yml View 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

+ 1
- 0
lang/zh.yml View File

@@ -637,3 +637,4 @@ enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪)
button_quote: Quote
setting_sequential_project_identifiers: Generate sequential project identifiers

+ 11
- 0
test/unit/project_test.rb View File

@@ -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

Loading…
Cancel
Save