return
end
- assignee = User.find params[:assignee_id] unless params[:assignee_id].blank?
+ assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank?
@review.assignee = assignee
@review.save
sanitize_violation(violation)
violation.build_review(:user_id => current_user.id)
- assignee = User.find params[:assignee_id] unless params[:assignee_id].blank?
+ assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank?
violation.review.assignee = assignee
violation.review.save!
violation.save
## -------------- PRIVATE -------------- ##
private
-
+
+ def findUserByLogin(login)
+ User.find(:all, :conditions => [ "login = ?", login ]).first
+ end
+
def init_params
- default_user = (current_user ? current_user.id : '')
- @assignee_id = params[:assignee_id] || default_user
- @author_id = params[:author_id] || ''
+ default_user = (current_user ? current_user.login : '')
+ @assignee_login = params[:assignee_login] || default_user
+ @author_login = params[:author_login] || ''
@severities = filter_any(params[:severities]) || ['']
@statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN, Review::STATUS_REOPENED]
@projects = filter_any(params[:projects]) || ['']
unless @severities == ['']
options['severities']=@severities.join(',')
end
- if @author_id
- options['authors']=@author_id.to_s
+ if @author_login
+ options['authors']=@author_login
end
- if @assignee_id
- options['assignees']=@assignee_id.to_s
+ if @assignee_login
+ options['assignees']=@assignee_login
end
if @false_positives
options['false_positives']=@false_positives
param_id_value = param_value
unless param_id_value.blank?
- user = User.find(param_id_value)
+ user = User.find(:all, :conditions => [ "login = ?", param_id_value ]).first
param_displayed_value = user.name if user
- param_displayed_value += " (me)" if user && current_user && current_user.id == param_id_value.to_i
+ param_displayed_value += " (me)" if user && current_user && current_user.login == param_id_value
end
server_url = url_for :controller => 'users', :action => 'autocomplete'
<form method="post"
- onsubmit="if ($('assignee_id').value != '') { new Ajax.Updater('review', '<%= url_for :action => 'assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;">
+ onsubmit="if ($('assignee_login').value != '') { new Ajax.Updater('review', '<%= url_for :action => 'assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;">
<%= hidden_field_tag :id, params[:review_id] -%>
- <%= user_autocomplete_field "assignee_id", "" -%>
+ <%= user_autocomplete_field "assignee_login", "" -%>
<%= submit_to_remote "submit_btn", "Assign",
:url => { :action => 'assign' },
:url => { :action => 'show', :id => params[:review_id] },
:update => "review" %>
<script>
- $('autocompleteText-assignee_id').focus()
+ $('autocompleteText-assignee_login').focus()
</script>
</form>
\ No newline at end of file
<%= image_tag("sep12.png") -%>
<form method="post"
- onsubmit="if ($('assignee_id').value != '') { new Ajax.Updater('vId<%= params[:violation_id] -%>', '<%= url_for :action => 'violation_assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;">
+ onsubmit="if ($('assignee_login').value != '') { new Ajax.Updater('vId<%= params[:violation_id] -%>', '<%= url_for :action => 'violation_assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;">
<%= hidden_field_tag :id, params[:violation_id] -%>
- <%= user_autocomplete_field "assignee_id", "" -%>
+ <%= user_autocomplete_field "assignee_login", "" -%>
<%= submit_to_remote "submit_btn", "Assign",
:url => { :action => 'violation_assign' },
:url => { :action => 'display_violation', :id => params[:violation_id] },
:update => "vId" + params[:violation_id] %>
<script>
- $('autocompleteText-assignee_id').focus()
+ $('autocompleteText-assignee_login').focus()
</script>
</form>
\ No newline at end of file
</td>
<td width="1%" nowrap>
<span class="note">Created by</span><br/>
- <%= user_autocomplete_field "author_id", @author_id, { :class => "max-width" } -%>
+ <%= user_autocomplete_field "author_login", @author_login, { :class => "max-width" } -%>
<br/>
<span class="note">Assigned to</span><br/>
- <%= user_autocomplete_field "assignee_id", @assignee_id, { :class => "max-width" } -%>
+ <%= user_autocomplete_field "assignee_login", @assignee_login, { :class => "max-width" } -%>
<br/>
<br/>
<select name="false_positives" id="false_positives" onchange="if(this.value=='only' || this.value=='with') {$('assignee_id').value = ''; $('autocompleteText-assignee_id').value = '';};">
-<% current_user_id = current_user.id if current_user %>
+<% current_user_login = current_user.login if current_user %>
<ul>
<%
@users.each do |user|
user_name = user.name
%>
- <li id="<%= h(user.id) -%>"><strong><%= h(user_name)[0..@char_count-1] -%></strong><%= h(user_name)[@char_count..user_name.size-1] -%> <i><%= "(me)" if current_user_id == user.id -%></i></li>
+ <li id="<%= h(user.login) -%>"><strong><%= h(user_name)[0..@char_count-1] -%></strong><%= h(user_name)[@char_count..user_name.size-1] -%> <i><%= "(me)" if current_user_login == user.login -%></i></li>
<% end %>
</ul>