Modified: branches/event_logging/app/helpers/application_helper.rb (1869 => 1870)
--- branches/event_logging/app/helpers/application_helper.rb 2008-10-17 10:50:38 UTC (rev 1869)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-10-17 13:36:32 UTC (rev 1870)
@@ -1546,9 +1546,11 @@
shared_with_name_or_title = shared_with.to_s
end
- # TODO: check that if not found by sql, RecordNotFound exception is raised
shared_what_links_arr = []
items_shared_with_this_permission = Contribution.find_by_sql("SELECT contributable_type, contributable_id FROM Contributions WHERE policy_id = #{permission.policy_id}")
+ if items_shared_with_this_permission.empty?
+ raise ActiveRecord::RecordNotFound, "Couldn't find any contributions associated with Policy ID = #{permission.policy_id}"
+ end
items_shared_with_this_permission.each do |item|
object, path = evaluate_object_instance_and_path(item.contributable_type, item.contributable_id)
shared_what_links_arr << link_to(object.title, path)
@@ -1608,7 +1610,19 @@
when "Review"
if action == "create"
begin
- # TODO
+ # reviews are currently only available for workflows, but the news generation is done in a generic way
+ review = Review.find(log_entry.activity_loggable_id)
+ review_path = eval("#{log_entry.referenced_type.downcase}_review_path(#{log_entry.referenced_id},#{review.id})")
+ if review.title.blank?
+ reviewed_link = review_path
+ review_title_link = ""
+ else
+ reviewed_link = nil
+ review_title_link = ": \"" + link_to(review.title, review_path) + "\""
+ end
+ object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
+
+ rtn << [timestamp, "#{name(log_entry.culprit_id)} #{link_to_unless reviewed_link.nil?, "reviewed", reviewed_link} #{link_to object.title, object_path} #{model_visible_name(log_entry.referenced_type.to_s)}#{review_title_link}"]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing review / object
end
@@ -1618,7 +1632,24 @@
when "Creditation"
if action == "create"
begin
- # TODO
+ creditation = Creditation.find(log_entry.activity_loggable_id)
+ object, object_path = evaluate_object_instance_and_path(creditation.creditable_type, creditation.creditable_id)
+
+ # wording for credit to the user themself follows a different pattern
+ if (log_entry.culprit_type == log_entry.referenced_type && log_entry.culprit_id == log_entry.referenced_id)
+ credited_whom = "themself"
+ else
+ case log_entry.referenced_type
+ when "User"
+ credited_whom = name(log_entry.referenced_id)
+ when "Network"
+ credited_whom = "the #{title(log_entry.referenced_id)} Group"
+ else
+ credited_whom = "(#{log_entry.referenced_type},#{log_entry.referenced_id})"
+ end
+ end
+
+ rtn << [timestamp, "#{name(log_entry.culprit_id)} credited #{credited_whom} for #{link_to object.title, object_path} #{model_visible_name(object.class.to_s)}"]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing creditation / object
end
@@ -1627,7 +1658,24 @@
when "Attribution"
if action == "create"
begin
- # TODO
+ attribution = Attribution.find(log_entry.activity_loggable_id)
+ attributed_what, attributed_what_path = evaluate_object_instance_and_path(attribution.attributable_type, attribution.attributable_id)
+ attributed_to, attributed_to_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
+
+ attribution_visible_titles = []
+ attribution_objects = [attributed_what, attributed_to]
+ attribution_objects.each do |o|
+ case o.class.to_s
+ when "Blob"
+ attribution_visible_titles << ((o.title && o.title.length > 0) ? h(o.title) : h(o.local_name))
+ when "Workflow"
+ attribution_visible_titles << o.title
+ else
+ attribution_visible_titles << "(#{o.class.to_s},#{o.id})"
+ end
+ end
+
+ rtn << [timestamp, "#{name(log_entry.culprit_id)} attributed #{link_to attribution_visible_titles[0], attributed_what_path} #{model_visible_name(attributed_what.class.to_s)} to #{link_to attribution_visible_titles[1], attributed_to_path} #{model_visible_name(attributed_to.class.to_s)}"]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing creditation / object
end