Commit 47e29180 authored by jplang's avatar jplang

Makes repository url read-only after saving.

git-svn-id: https://svn.redmine.org/redmine/trunk@9878 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 85573b24
......@@ -159,7 +159,7 @@ module RepositoriesHelper
def subversion_field_tags(form, repository)
content_tag('p', form.text_field(:url, :size => 60, :required => true,
:disabled => (repository && !repository.root_url.blank?)) +
:disabled => !repository.safe_attribute?('url')) +
'<br />'.html_safe +
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
content_tag('p', form.text_field(:login, :size => 30)) +
......@@ -174,7 +174,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
:disabled => (repository && !repository.new_record?))) +
:disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true))
......@@ -184,7 +184,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
:disabled => (repository && !repository.root_url.blank?)
:disabled => !repository.safe_attribute?('url')
) +
'<br />'.html_safe + l(:text_mercurial_repository_note)) +
content_tag('p', form.select(
......@@ -198,7 +198,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
:disabled => (repository && !repository.root_url.blank?)
:disabled => !repository.safe_attribute?('url')
) +
'<br />'.html_safe +
l(:text_git_repository_note)) +
......@@ -218,12 +218,12 @@ module RepositoriesHelper
:root_url,
:label => l(:field_cvsroot),
:size => 60, :required => true,
:disabled => !repository.new_record?)) +
:disabled => !repository.safe_attribute?('root_url'))) +
content_tag('p', form.text_field(
:url,
:label => l(:field_cvs_module),
:size => 30, :required => true,
:disabled => !repository.new_record?)) +
:disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true)) +
......@@ -238,7 +238,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
:disabled => (repository && !repository.new_record?))) +
:disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true))
......@@ -248,7 +248,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_root_directory),
:size => 60, :required => true,
:disabled => (repository && !repository.root_url.blank?))) +
:disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_scm_path_encoding)
......
......@@ -44,13 +44,15 @@ class Repository < ActiveRecord::Base
validate :repo_create_validation, :on => :create
safe_attributes 'identifier',
'url',
'login',
'password',
'path_encoding',
'log_encoding',
'is_default'
safe_attributes 'url',
:if => lambda {|repository, user| repository.new_record?}
def repo_create_validation
unless Setting.enabled_scm.include?(self.class.name.demodulize)
errors.add(:type, :invalid)
......
......@@ -21,7 +21,8 @@ require 'digest/sha1'
class Repository::Cvs < Repository
validates_presence_of :url, :root_url, :log_encoding
safe_attributes 'root_url'
safe_attributes 'root_url',
:if => lambda {|repository, user| repository.new_record?}
def self.human_attribute_name(attribute_key_name, *args)
attr_name = attribute_key_name.to_s
......
......@@ -40,7 +40,7 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_template 'new'
assert_kind_of Repository::Subversion, assigns(:repository)
assert assigns(:repository).new_record?
assert_tag 'input', :attributes => {:name => 'repository[url]'}
assert_tag 'input', :attributes => {:name => 'repository[url]', :disabled => nil}
end
def test_new_should_propose_enabled_scm_only
......@@ -91,7 +91,7 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_response :success
assert_template 'edit'
assert_equal Repository.find(11), assigns(:repository)
assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test'}
assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test', :disabled => 'disabled'}
end
def test_update
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment