diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 90eddd7b297..65f346d5fe3 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -20,13 +20,13 @@ class ProjectsController < ApplicationController
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
- before_filter :find_project, :except => [ :index, :list, :add, :copy ]
- before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy]
- before_filter :authorize_global, :only => :add
+ before_filter :find_project, :except => [ :index, :list, :add, :create, :copy ]
+ before_filter :authorize, :except => [ :index, :list, :add, :create, :copy, :archive, :unarchive, :destroy]
+ before_filter :authorize_global, :only => [:add, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_key_auth :index
- after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
+ after_filter :only => [:create, :edit, :archive, :unarchive, :destroy] do |controller|
if controller.request.post?
controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
end
@@ -65,35 +65,41 @@ def add
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.all
@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 = Setting.default_projects_modules
+
+ @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 = Setting.default_projects_modules
+ end
+
+ def create
+ @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
+ @trackers = Tracker.all
+ @project = Project.new(params[:project])
+
+ @project.enabled_module_names = params[:enabled_modules]
+ if validate_parent_id && @project.save
+ @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ # Add current user as a project member if he is not admin
+ unless User.current.admin?
+ r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
+ m = Member.new(:user => User.current, :roles => [r])
+ @project.members << m
+ end
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ }
+ format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
+ end
else
- @project.enabled_module_names = params[:enabled_modules]
- if validate_parent_id && @project.save
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
- # Add current user as a project member if he is not admin
- unless User.current.admin?
- r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
- m = Member.new(:user => User.current, :roles => [r])
- @project.members << m
- end
- respond_to do |format|
- format.html {
- flash[:notice] = l(:notice_successful_create)
- redirect_to :controller => 'projects', :action => 'settings', :id => @project
- }
- format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
- end
- else
- respond_to do |format|
- format.html
- format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
- end
+ respond_to do |format|
+ format.html { render :action => 'add' }
+ format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
end
- end
+ end
+
end
def copy
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0354d165d78..b854850a3b3 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -95,7 +95,9 @@ def edit
if request.post?
@user.admin = params[:user][:admin] if params[:user][:admin]
@user.login = params[:user][:login] if params[:user][:login]
- @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
+ if params[:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
+ end
@user.group_ids = params[:user][:group_ids] if params[:user][:group_ids]
@user.attributes = params[:user]
# Was the account actived ? (do it before User#save clears the change)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 19dd654db9c..0fb44a22bfe 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -32,8 +32,27 @@ def authorize_for(controller, action)
end
# Display a link if user is authorized
+ #
+ # @param [String] name Anchor text (passed to link_to)
+ # @param [Hash, String] options Hash params or url for the link target (passed to link_to).
+ # This will checked by authorize_for to see if the user is authorized
+ # @param [optional, Hash] html_options Options passed to link_to
+ # @param [optional, Hash] parameters_for_method_reference Extra parameters for link_to
def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
- link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
+ if options.is_a?(String)
+ begin
+ route = ActionController::Routing::Routes.recognize_path(options.gsub(/\?.*/,''), :method => options[:method] || :get)
+ link_controller = route[:controller]
+ link_action = route[:action]
+ rescue ActionController::RoutingError # Parse failed, not a route
+ link_controller, link_action = nil, nil
+ end
+ else
+ link_controller = options[:controller] || params[:controller]
+ link_action = options[:action]
+ end
+
+ link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(link_controller, link_action)
end
# Display a link to remote if user is authorized
diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb
index 990bfb1e574..c8d53f253be 100644
--- a/app/helpers/journals_helper.rb
+++ b/app/helpers/journals_helper.rb
@@ -39,11 +39,4 @@ def link_to_in_place_notes_editor(text, field_id, url, options={})
onclick = "new Ajax.Request('#{url_for(url)}', {asynchronous:true, evalScripts:true, method:'get'}); return false;"
link_to text, '#', options.merge(:onclick => onclick)
end
-
- def css_journal_classes(journal)
- s = 'journal'
- s << ' has-notes' unless journal.notes.blank?
- s << ' has-details' unless journal.details.blank?
- s
- end
end
diff --git a/app/models/journal.rb b/app/models/journal.rb
index a0e1ae8779e..3e846aeb89c 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -65,4 +65,12 @@ def project
def attachments
journalized.respond_to?(:attachments) ? journalized.attachments : nil
end
+
+ # Returns a string of css classes
+ def css_classes
+ s = 'journal'
+ s << ' has-notes' unless notes.blank?
+ s << ' has-details' unless details.blank?
+ s
+ end
end
diff --git a/app/views/issues/_history.rhtml b/app/views/issues/_history.rhtml
index 4ea2dd2ac39..4851e5f228b 100644
--- a/app/views/issues/_history.rhtml
+++ b/app/views/issues/_history.rhtml
@@ -1,6 +1,6 @@
<% reply_links = authorize_for('issues', 'edit') -%>
<% for journal in journals %>
-
+
<%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %>
<%= avatar(journal.user, :size => "24") %>
<%= content_tag('a', '', :name => "note-#{journal.indice}")%>
diff --git a/app/views/issues/_relations.rhtml b/app/views/issues/_relations.rhtml
index 71eaaa6737c..5b27fa6a577 100644
--- a/app/views/issues/_relations.rhtml
+++ b/app/views/issues/_relations.rhtml
@@ -28,6 +28,7 @@
<% remote_form_for(:relation, @relation,
:url => {:controller => 'issue_relations', :action => 'new', :issue_id => @issue},
:method => :post,
+ :complete => "Form.Element.focus('relation_issue_to_id');",
:html => {:id => 'new-relation-form', :style => (@relation ? '' : 'display: none;')}) do |f| %>
<%= render :partial => 'issue_relations/form', :locals => {:f => f}%>
<% end %>
diff --git a/app/views/projects/add.rhtml b/app/views/projects/add.rhtml
index d2ec5db9265..c8a9c7600d5 100644
--- a/app/views/projects/add.rhtml
+++ b/app/views/projects/add.rhtml
@@ -1,6 +1,6 @@
<%=l(:label_project_new)%>
-<% labelled_tabular_form_for :project, @project, :url => { :action => "add" } do |f| %>
+<% labelled_tabular_form_for :project, @project, :url => { :action => "create" } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>