]> source.dussan.org Git - redmine.git/commitdiff
Ability to disable unused SCM adapters in application settings.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jun 2008 14:59:26 +0000 (14:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jun 2008 14:59:26 +0000 (14:59 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1507 e93f8b46-1217-0410-a6f0-8f06a7374b81

34 files changed:
app/controllers/repositories_controller.rb
app/helpers/repositories_helper.rb
app/models/repository.rb
app/views/projects/settings/_repository.rhtml
app/views/settings/_repositories.rhtml
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/repository_test.rb

index 64eb05793e9f306fcaee6c8128a79e4cd5be9028..ea3b117d998becd090c8cc16e46b183bcbae5b44 100644 (file)
@@ -34,9 +34,9 @@ class RepositoriesController < ApplicationController
     @repository = @project.repository
     if !@repository
       @repository = Repository.factory(params[:repository_scm])
-      @repository.project = @project
+      @repository.project = @project if @repository
     end
-    if request.post?
+    if request.post? && @repository
       @repository.attributes = params[:repository]
       @repository.save
     end
index 22bdec9df986d30a240f3944de90e98fa4f9e477..d2cc664e617cc8a1388bd48bbc1d3e9c6d3ca351 100644 (file)
@@ -48,10 +48,13 @@ module RepositoriesHelper
   end
   
   def scm_select_tag(repository)
-    container = [[]]
-    REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
+    scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
+    REDMINE_SUPPORTED_SCM.each do |scm|
+      scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
+    end
+    
     select_tag('repository_scm', 
-               options_for_select(container, repository.class.name.demodulize),
+               options_for_select(scm_options, repository.class.name.demodulize),
                :disabled => (repository && !repository.new_record?),
                :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
                )
index 1ea77f24f003765d84aa1510f1320c0f573492e8..e6ed7da52b545c8d19592d4b7eb873253734e133 100644 (file)
@@ -19,7 +19,10 @@ class Repository < ActiveRecord::Base
   belongs_to :project
   has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
   has_many :changes, :through => :changesets
-    
+  
+  # Checks if the SCM is enabled when creating a repository
+  validate_on_create { |r| r.errors.add(:type, :activerecord_error_invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
+  
   # Removes leading and trailing whitespace
   def url=(arg)
     write_attribute(:url, arg ? arg.to_s.strip : nil)
index 95830ab98b9f43ffa1326f6986e5ab61a995ddde..dcfabbbf03e410b3561e52fee63d885670f61b27 100644 (file)
@@ -17,5 +17,5 @@
             :class => 'icon icon-del') if @repository && !@repository.new_record? %>
 </div>
 
-<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save)) %>
+<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %>
 <% end %>
index 59b3b51dee7f4158723d02296e3ef0b64dc774fe..127801be2b8212f1060cb042ff64fcad2427e11c 100644 (file)
@@ -7,6 +7,13 @@
 <p><label><%= l(:setting_sys_api_enabled) %></label>
 <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
 
+<p><label><%= l(:setting_enabled_scm) %></label>
+<% REDMINE_SUPPORTED_SCM.each do |scm| -%>
+<%= check_box_tag 'settings[enabled_scm][]', scm, Setting.enabled_scm.include?(scm) %> <%= scm %>
+<% end -%>
+<%= hidden_field_tag 'settings[enabled_scm][]', '' %>
+</p>
+
 <p><label><%= l(:setting_repositories_encodings) %></label>
 <%= text_field_tag 'settings[repositories_encodings]', Setting.repositories_encodings, :size => 60 %><br /><em><%= l(:text_comma_separated) %></em></p>
 </div>
index bb501823e4f03ec9643b00d579b1903a64540035..616665f23f5073e6e5199bf128b2d1102d467fea 100644 (file)
@@ -59,6 +59,15 @@ protocol:
 feeds_limit:
   format: int
   default: 15
+enabled_scm:
+  serialized: true
+  default: 
+  - Subversion
+  - Darcs
+  - Mercurial
+  - Cvs
+  - Bazaar
+  - Git
 autofetch_changesets:
   default: 1
 sys_api_enabled:
index 6ab6f26c6fc1d49c13f26470f1b9e95170dc8022..5f3548684083543982235ed02f2c5cf9dc9b43db 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 7413b79ddb2d4333e77652e337b236a8adda9f11..26e0f5131938069366874a828325400b445ea31b 100644 (file)
@@ -628,3 +628,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 2107498adf79669e8b2b6da8afcc439b521b8055..b2f18db4cc7f9f08f0c76273fa7f9263df2a3ab7 100644 (file)
@@ -625,3 +625,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 27d22fc544e49dd5ef053dea46d8e401b6138ff3..1e4040f3d1c22f4745b81fdfccd5aefe732e4c1e 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 262570f1ddb6e4fa65b034b61a74d77b687d16b8..b7f217e6c3084ca80b216c15e3ce96c7a3dfbf26 100644 (file)
@@ -213,6 +213,7 @@ setting_per_page_options: Objects per page options
 setting_user_format: Users display format
 setting_activity_days_default: Days displayed on project activity
 setting_display_subprojects_issues: Display subprojects issues on main projects by default
+setting_enabled_scm: Enabled SCM
 
 project_module_issue_tracking: Issue tracking
 project_module_time_tracking: Time tracking
index 62528e688ae59d9736cc4165edba5ded3f9ae5f5..c0ecb997bf9d220938b92a1f3f482c5c7fd36dae 100644 (file)
@@ -626,3 +626,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index b32bbb259797dec34b7c1ae1198c57654d263d6a..6ac4aea7ec90c62df9b5a5a903be4ce781d8a9b3 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 8b040463f7b7b773a6f482de795e1cecd8774e84..4db2f8f3ad3cb766a394e21ef4028b8f3c4901d7 100644 (file)
@@ -214,6 +214,7 @@ setting_per_page_options: Options d'objets affichés par page
 setting_user_format: Format d'affichage des utilisateurs
 setting_activity_days_default: Nombre de jours affichés sur l'activité des projets
 setting_display_subprojects_issues: Afficher par défaut les demandes des sous-projets sur les projets principaux
+setting_enabled_scm: SCM activés
 
 project_module_issue_tracking: Suivi des demandes
 project_module_time_tracking: Suivi du temps passé
index da31812cf90f7a67301ff7d50e5007ffe4e7c9fd..e23698d32bb92853d30098b0f9c4ff668e7c90aa 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 2a399bc139c12caa429995bc023b1657c28769a9..64518271c090a3efd7f8930e7d67900dc572099b 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d neked kiosztott feladat határidős az elkövetkező %d
 mail_subject_reminder: "%d feladat határidős az elkövetkező napokban"
 text_user_wrote: '%s írta:'
 label_duplicated_by: duplikálta
+setting_enabled_scm: Enabled SCM
index e5557f91583115da76963b958165bba3a0d3d3fd..5ab9ad310bcf88de96b5f2d35cd430c1634a5637 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 1ae9ab1b60f86da6f863e7cd5cba9254cf3c69dc..c693d68e5ade9a40311c82ec4d3d1fe4bf8cc266 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index c00a9e9a0e9577fff3b3d60b660b94c2ca5e6473..af1c768afc9ecf6a85ee37eab621dad44f2aac5c 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 140631fcf6c9fc2141007e98394d672326b138e6..ff8f6b695e0ea1a9a942b16a09d1e94994d64fea 100644 (file)
@@ -625,3 +625,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 62bbc146842ddfedb4cecba26470cf94d2401b0c..9ee9138480fcb5cd2d86c1fedf860fe0f0085623 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index a31751da68e10ca5bfb4bfa0043243577d74d494..e3b88b110be3f4c0f43abef9b1ba3f55d0c8ddb1 100644 (file)
@@ -624,3 +624,4 @@ default_activity_development: Utvikling
 enumeration_issue_priorities: Sakssprioriteringer
 enumeration_doc_categories: Dokument-kategorier
 enumeration_activities: Aktiviteter (tidssporing)
+setting_enabled_scm: Enabled SCM
index adf67621036f7de826c41d49f196e2dab4dadef3..75e04ecd43904b46ddad8703b0a0a7a8caa33e4e 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index ca9b9073bb675e141ebfc8f82ded156378a6432b..dabab5bfeb561d6c1db51751be6883852d5d681d 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"\r
 text_user_wrote: '%s wrote:'\r
 label_duplicated_by: duplicated by\r
+setting_enabled_scm: Enabled SCM\r
index f9472b7ea49ed84de95afbc7a15fc1f24feb9c67..2845f390cdb70082070d60f05a8d16e777a127c6 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 840fa7073d8b63c3495d59d046cf7c100706053a..dd51e59be001681e60e75dd808634a2166668c00 100644 (file)
@@ -623,3 +623,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 37f2aef301b051630e5a49648199ba253b83f30e..c3ec91897c138bbcb5c39db8831e34ab81e6bbcd 100644 (file)
@@ -627,3 +627,4 @@ mail_body_reminder: "%d назначенных на вас задач на сл
 mail_subject_reminder: "%d назначенных на вас задач в ближайшие дни" 
 text_user_wrote: '%s написал:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index d507a1d97b07fb1168263b065f6868cf264fedec..92906760b88b40f2050f983d1b96a54049c99427 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index fbd7c5c408372537e8762bf86944b8eafde9f9b5..f08e45eb0b6c0fa7338a3424023d8704059e0226 100644 (file)
@@ -624,3 +624,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 9dfaf2865c27909b405ab181fac3fe23ba558d6f..85a1f8c017d04d46040f4eef3670b6cb2b2bce76 100644 (file)
@@ -626,3 +626,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index beabfd1f071200626b45db93424babfd3dca5f60..ae8c5cbc09a6828e00d38e76bbb4c5d8a74c7ed7 100644 (file)
@@ -625,3 +625,4 @@ mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d
 mail_subject_reminder: "%d issue(s) due in the next days"
 text_user_wrote: '%s wrote:'
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index c3cd096a3f28fdb498fde2fa9e5ebe99beef2ef7..2ee595dcdc280c458154b12c619c3530176761a8 100644 (file)
@@ -624,3 +624,4 @@ default_activity_development: 開發
 enumeration_issue_priorities: 項目優先權
 enumeration_doc_categories: 文件分類
 enumeration_activities: 活動 (時間追蹤)
+setting_enabled_scm: Enabled SCM
index 9e22e6874bd2e528f4cc1f8fd6a97a440873bf7f..d823634146b6e481b345fbc51fa6f7e8b600383b 100644 (file)
@@ -624,3 +624,4 @@ enumeration_issue_priorities: 问题优先级
 enumeration_doc_categories: 文档类别
 enumeration_activities: 活动(时间跟踪)
 label_duplicated_by: duplicated by
+setting_enabled_scm: Enabled SCM
index 7764ee04a2c173b5869be312eeb9aec3d944a693..270b0bea1d28992295ccefb4fa3d048e6f106694 100644 (file)
@@ -45,6 +45,14 @@ class RepositoryTest < Test::Unit::TestCase
     assert_equal repository, project.repository\r
   end
   
+  def test_should_not_create_with_disabled_scm
+    # disable Subversion
+    Setting.enabled_scm = ['Darcs', 'Git']
+    repository = Repository::Subversion.new(:project => Project.find(3), :url => "svn://localhost")
+    assert !repository.save
+    assert_equal :activerecord_error_invalid, repository.errors.on(:type)
+  end
+  
   def test_scan_changesets_for_issue_ids
     # choosing a status to apply to fix issues
     Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id