Modified: trunk/app/helpers/application_helper.rb (2183 => 2184)
--- trunk/app/helpers/application_helper.rb 2009-04-29 14:45:30 UTC (rev 2183)
+++ trunk/app/helpers/application_helper.rb 2009-04-29 19:11:14 UTC (rev 2184)
@@ -816,41 +816,33 @@
return rtn
end
-
- def effective_policy(contribution)
- if contribution.policy == nil
- return Policy._default(contribution.contributor)
- else
- return contribution.policy
- end
+ def workflows_for_attribution_form
+ workflows = Workflow.find(:all, :select => 'workflows.id, workflows.title, users.name',
+ :joins => 'LEFT OUTER JOIN users ON workflows.contributor_type = "User" AND workflows.contributor_id = users.id',
+ :order => 'workflows.title ASC')
+
+ workflows.select { |w| Authorization.is_authorized?('show', 'Workflow', w.id, current_user) }
end
- def all_workflows
- workflows = Workflow.find(:all, :order => "title ASC")
- workflows = workflows.select {|w| Authorization.is_authorized?('show', nil, w, current_user) }
+ def blobs_for_attribution_form
+ blobs = Blob.find(:all, :select => 'blobs.id, blobs.title, users.name',
+ :joins => 'LEFT OUTER JOIN users ON blobs.contributor_type = "User" AND blobs.contributor_id = users.id',
+ :order => 'blobs.title ASC')
+
+ blobs.select { |b| Authorization.is_authorized?('show', 'Blob', b.id, current_user) }
end
- def all_blobs
- blobs = Blob.find(:all)
- blobs.sort! { |x,y|
- x_title = (x.title and x.title.length > 0) ? x.title : x.local_name
- y_title = (y.title and y.title.length > 0) ? y.title : y.local_name
- x_title.downcase <=> y_title.downcase
- }
- blobs = blobs.select {|b| Authorization.is_authorized?('show', nil, b, current_user) }
+ def networks_for_credits_form
+ Network.find(:all, :select => 'id, title',
+ :order => "title ASC")
end
- def all_networks
- Network.find(:all, :order => "title ASC")
+ def nonfriends_for_credits_form(user)
+ User.find(:all, :select => 'id, name',
+ :order => 'LOWER(name)',
+ :conditions => ["id != ?", user.id]) - user.friends
end
-
- def all_nonfriends(user)
- users = User.find(:all) - user.friends - [ user ]
- users.sort! { |x,y|
- x.name.downcase <=> y.name.downcase
- }
- end
def all_users
users = User.find(:all)
Modified: trunk/app/views/contributions/_credit_attribution_form.rhtml (2183 => 2184)
--- trunk/app/views/contributions/_credit_attribution_form.rhtml 2009-04-29 14:45:30 UTC (rev 2183)
+++ trunk/app/views/contributions/_credit_attribution_form.rhtml 2009-04-29 19:11:14 UTC (rev 2184)
@@ -70,7 +70,7 @@
<div id="author_otheruser_box" style="display: none; padding-left: 2em;">
<p>
<select id="author_otheruser_dropdown">
- <% (all_nonfriends(current_user)).each do |f| %>
+ <% (nonfriends_for_credits_form(current_user)).each do |f| %>
<option value="<%= f.id %>"><%= h(f.name) %></option>
<% end %>
</select>
@@ -85,7 +85,7 @@
<div id="author_networks_box" style="display: none; padding-left: 2em;">
<p>
<select id="author_networks_dropdown">
- <% all_networks.each do |n| %>
+ <% networks_for_credits_form.each do |n| %>
<option value="<%= n.id %>"><%= h(n.title) %></option>
<% end %>
</select>
@@ -139,8 +139,8 @@
<br />
<br />
<select id="existingworkflows_dropdown" style="width: 280px;">
- <% all_workflows.each do |w| %>
- <option value="<%= w.id %>"><%= h(w.title) -%> (<%= contributor_name(w.contribution.contributor_id, w.contribution.contributor_type) -%>)</option>
+ <% workflows_for_attribution_form.each do |w| %>
+ <option value="<%= w.id %>"><%= h(w.title) -%> (<%= h(w.name) -%>)</option>
<% end %>
</select>
<br />
@@ -153,8 +153,8 @@
<br />
<br />
<select id="existingfiles_dropdown" style="width: 280px;">
- <% all_blobs.each do |b| %>
- <option value="<%= b.id %>"><%= contributable_name(b.id, 'Blob') -%> (<%= contributor_name(b.contributor_id, b.contributor_type) -%>)</option>
+ <% blobs_for_attribution_form.each do |b| %>
+ <option value="<%= b.id %>"><%= h(b.title) -%> (<%= h(b.name) -%>)</option>
<% end %>
</select>
<br />