Mercurial > hg > soundsoftware-site
changeset 1355:3d01be97cb5a bug_635
Fix routes and safe attributes for the external repo settings
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Thu, 18 Jul 2013 12:13:20 +0100 |
parents | fc0fecf09eb9 |
children | b8f94812d737 ab8bd24eeb65 |
files | app/controllers/repositories_controller.rb app/models/repository.rb app/views/projects/settings/_repositories.html.erb public/javascripts/repository.js |
diffstat | 4 files changed, 15 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/repositories_controller.rb Thu Jul 18 11:18:35 2013 +0100 +++ b/app/controllers/repositories_controller.rb Thu Jul 18 12:13:20 2013 +0100 @@ -60,21 +60,6 @@ end def edit - @repository = @project.repository - params[:repository_scm]='Mercurial' - if !@repository - @repository = Repository.factory(params[:repository_scm]) - @repository.project = @project if @repository - end - if request.post? && @repository - attrs = pickup_extra_info - @repository.safe_attributes = attrs[:attrs] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - @repository.project = @project - redirect_to settings_project_path(@project, :tab => 'repositories') - end end def update
--- a/app/models/repository.rb Thu Jul 18 11:18:35 2013 +0100 +++ b/app/models/repository.rb Thu Jul 18 12:13:20 2013 +0100 @@ -51,6 +51,8 @@ 'password', 'path_encoding', 'log_encoding', + 'is_external', + 'external_url', 'is_default' safe_attributes 'url',
--- a/app/views/projects/settings/_repositories.html.erb Thu Jul 18 11:18:35 2013 +0100 +++ b/app/views/projects/settings/_repositories.html.erb Thu Jul 18 12:13:20 2013 +0100 @@ -1,18 +1,19 @@ <%= javascript_include_tag 'repository' %> +<% if @repository %> + <%= form_for @repository, :as => :repository, - :url => { :controller => 'repositories', :action => 'edit', :id => @project }, :remote => true, - :method => 'post' do |f| %> + :url => { :controller => 'repositories', :action => 'update', :id => @repository }, + :method => 'put' do |f| %> <%= error_messages_for 'repository' %> <div class="box tabular"> <p> -<% if @repository %> <%= l(:text_settings_repo_explanation).html_safe %></ br> <% if @repository.is_external %> <p><%= l(:text_settings_repo_is_external).html_safe %></ br> @@ -44,7 +45,7 @@ { :controller => 'repositories', :action => 'committers', - :id => @project + :id => @repository }, :class => 'icon icon-user') %> <% end %> @@ -52,8 +53,9 @@ <%= submit_tag(l(:button_save)) %> +<% end %> + <% else %> <%= l(:text_settings_repo_creation).html_safe %></ br> <% end %> -<% end %>
--- a/public/javascripts/repository.js Thu Jul 18 11:18:35 2013 +0100 +++ b/public/javascripts/repository.js Thu Jul 18 12:13:20 2013 +0100 @@ -1,7 +1,8 @@ -function toggle_ext_url(){ - if($('repository_is_external').checked) - $('repository_external_url').enable(); - else - $('repository_external_url').disable(); +function toggle_ext_url() { + if (document.getElementById('repository_is_external').checked) { + document.getElementById('repository_external_url').disabled = false; + } else { + document.getElementById('repository_external_url').disabled = true; + } }