diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-06-08 14:59:26 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-06-08 14:59:26 +0000 |
commit | dfe62d7f51b4aadb1034e2e64de2524b30dfd17b (patch) | |
tree | 30356cfb29fe20a91246f08aa8656e216c331f15 /app | |
parent | 05cd95987f1946f2bce138d339ef64511e15bde6 (diff) | |
download | redmine-dfe62d7f51b4aadb1034e2e64de2524b30dfd17b.tar.gz redmine-dfe62d7f51b4aadb1034e2e64de2524b30dfd17b.zip |
Ability to disable unused SCM adapters in application settings.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1507 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/repositories_controller.rb | 4 | ||||
-rw-r--r-- | app/helpers/repositories_helper.rb | 9 | ||||
-rw-r--r-- | app/models/repository.rb | 5 | ||||
-rw-r--r-- | app/views/projects/settings/_repository.rhtml | 2 | ||||
-rw-r--r-- | app/views/settings/_repositories.rhtml | 7 |
5 files changed, 20 insertions, 7 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 64eb05793..ea3b117d9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 22bdec9df..d2cc664e6 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -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)") ) diff --git a/app/models/repository.rb b/app/models/repository.rb index 1ea77f24f..e6ed7da52 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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) diff --git a/app/views/projects/settings/_repository.rhtml b/app/views/projects/settings/_repository.rhtml index 95830ab98..dcfabbbf0 100644 --- a/app/views/projects/settings/_repository.rhtml +++ b/app/views/projects/settings/_repository.rhtml @@ -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 %> diff --git a/app/views/settings/_repositories.rhtml b/app/views/settings/_repositories.rhtml index 59b3b51de..127801be2 100644 --- a/app/views/settings/_repositories.rhtml +++ b/app/views/settings/_repositories.rhtml @@ -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> |