144 |
144 |
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x,
|
145 |
145 |
:customized => @issue,
|
146 |
146 |
:value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
|
|
147 |
|
|
148 |
# Create search string to find this issues author
|
|
149 |
user_name = params[:user][:name]
|
|
150 |
case Setting.user_format
|
|
151 |
when :firstname_lastname then search = ['firstname = ? AND lastname = ?', user_name.split(' ')[0], user_name.split(' ')[1]]
|
|
152 |
when :firstname then search = ['firstname = ?', user_name]
|
|
153 |
when :lastname_firstname then search = ['lastname = ? AND firstname = ?', user_name.split(' ')[0], user_name.split(' ')[1]]
|
|
154 |
when :lastname_coma_firstname then search = ['lastname = ? AND firstname = ?', user_name.split(', ')[0], user_name.split(', ')[1]]
|
|
155 |
when :username then search = ['login = ?', user_name]
|
|
156 |
end
|
|
157 |
|
|
158 |
# FIXME: user search below assumes there is only one
|
|
159 |
# individual with this firstname/lastname combination
|
|
160 |
@issue.author = User.find(:first, :conditions => search)
|
|
161 |
|
|
162 |
if @issue.author.nil?
|
|
163 |
flash[:error] = "Can't find #{l(:field_author)} entered."
|
|
164 |
redirect_to :controller => 'issues', :action => 'new', :issue => params[:issue]
|
|
165 |
return
|
|
166 |
end
|
|
167 |
|
147 |
168 |
@issue.custom_values = @custom_values
|
148 |
169 |
if @issue.save
|
149 |
170 |
attach_files(@issue, params[:attachments])
|
... | ... | |
157 |
178 |
render :layout => !request.xhr?
|
158 |
179 |
end
|
159 |
180 |
|
|
181 |
def auto_complete_for_user_name
|
|
182 |
search = params[:user][:name]
|
|
183 |
@users = Project.find_by_identifier(params[:project]).users.find(:all,
|
|
184 |
:conditions => ['LOWER(lastname) LIKE ?', "#{search.downcase}%"],
|
|
185 |
:order => 'lastname ASC',
|
|
186 |
:limit => 10) unless search.blank?
|
|
187 |
render :partial => "user_search"
|
|
188 |
end
|
|
189 |
|
160 |
190 |
# Attributes that can be updated on workflow transition (without :edit permission)
|
161 |
191 |
# TODO: make it configurable (at least per role)
|
162 |
192 |
UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
|