Modified: branches/event_logging/app/helpers/application_helper.rb (1871 => 1872)
--- branches/event_logging/app/helpers/application_helper.rb 2008-10-17 15:57:59 UTC (rev 1871)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-10-17 17:03:27 UTC (rev 1872)
@@ -1475,6 +1475,13 @@
timestamp = log_entry.created_at
# TODO: add basic check that culprit exists
+ unless ["Membership", "User"].include? loggable_type.to_s
+ # for all "activity_loggables" apart from those above, the culprit is the "user";
+ # if "name" helper return 'nil' - this means that the user not found
+ # -> news item not to be shown then
+ culprit_link = name(log_entry.culprit_id)
+ return rtn if culprit_link.nil?
+ end
case loggable_type.to_s
when "Workflow", "Blob", "Pack"
@@ -1484,7 +1491,7 @@
object, object_path = evaluate_object_instance_and_path(log_entry.activity_loggable_type, log_entry.activity_loggable_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} #{action}d the #{link_to object_visible_name, object_path} #{model_visible_name(loggable_type.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} #{action}d the #{link_to object_visible_name, object_path} #{model_visible_name(loggable_type.to_s)}."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing contributable item
end
@@ -1525,20 +1532,20 @@
when "Friendship"
case action
when "create"
- rtn << [timestamp, "#{name(log_entry.culprit_id)} requested friendship with #{name(log_entry.referenced_id)}."]
+ rtn << [timestamp, "#{culprit_link} requested friendship with #{name(log_entry.referenced_id)}."]
when "accept"
- rtn << [timestamp, "#{name(log_entry.culprit_id)} and #{name(log_entry.referenced_id)} became friends."]
+ rtn << [timestamp, "#{culprit_link} and #{name(log_entry.referenced_id)} became friends."]
when "reject"
- rtn << [timestamp, "#{name(log_entry.culprit_id)} rejected a friendship request from #{name(log_entry.referenced_id)}."]
+ rtn << [timestamp, "#{culprit_link} rejected a friendship request from #{name(log_entry.referenced_id)}."]
when "destroy"
- rtn << [timestamp, "#{name(log_entry.culprit_id)} removed #{name(log_entry.referenced_id)} from their friends list."]
+ rtn << [timestamp, "#{culprit_link} removed #{name(log_entry.referenced_id)} from their friends list."]
end
when "Network"
if action == "create"
begin
network = Network.find(log_entry.activity_loggable_id)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} created the #{link_to(h(network.title), group_path(network))} Group."]
+ rtn << [timestamp, "#{culprit_link} created the #{link_to(h(network.title), group_path(network))} Group."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing group
end
@@ -1550,7 +1557,7 @@
ann = GroupAnnouncement.find(log_entry.activity_loggable_id)
group = Network.find(log_entry.referenced_id)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} made an announcement \"#{link_to ann.title, group_announcement_path(log_entry.referenced_id, ann.id)}\" for group #{link_to group.title, group_path(group)}."]
+ rtn << [timestamp, "#{culprit_link} made an announcement \"#{link_to ann.title, group_announcement_path(log_entry.referenced_id, ann.id)}\" for group #{link_to group.title, group_path(group)}."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing group announcement / group
end
@@ -1600,7 +1607,7 @@
shared_what_links_arr << link_to(object_visible_name, path)
end
- rtn << [timestamp, "#{name(log_entry.culprit_id)} shared #{access_rights} #{shared_what_links_arr.join(", ")} with #{link_to shared_with_name_or_title, shared_with_path} #{model_visible_name(shared_with.class.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} shared #{access_rights} #{shared_what_links_arr.join(", ")} with #{link_to shared_with_name_or_title, shared_with_path} #{model_visible_name(shared_with.class.to_s)}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing permission / network or user to which it refers to
@@ -1615,7 +1622,7 @@
object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} rated #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} #{rating.rating} out of 5."]
+ rtn << [timestamp, "#{culprit_link} rated #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} #{rating.rating} out of 5."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing rating / object
end
@@ -1633,7 +1640,7 @@
object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} added #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} to #{link_to "favourites", user_path(log_entry.culprit_id) + "/favourites"}."]
+ rtn << [timestamp, "#{culprit_link} added #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} to #{link_to "favourites", user_path(log_entry.culprit_id) + "/favourites"}."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing bookmark / object
end
@@ -1647,7 +1654,7 @@
object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} #{link_to "commented", object_path + "#comment_" + comment.id.to_s} on #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} #{link_to "commented", object_path + "#comment_" + comment.id.to_s} on #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)}."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing comment / object
end
@@ -1670,7 +1677,7 @@
object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} #{link_to_unless reviewed_link.nil?, "reviewed", reviewed_link} #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)}#{review_title_link}."]
+ rtn << [timestamp, "#{culprit_link} #{link_to_unless reviewed_link.nil?, "reviewed", reviewed_link} #{link_to object_visible_name, 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
@@ -1698,7 +1705,7 @@
end
end
- rtn << [timestamp, "#{name(log_entry.culprit_id)} credited #{credited_whom} for #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} credited #{credited_whom} for #{link_to object_visible_name, 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
@@ -1713,7 +1720,7 @@
attributed_to, attributed_to_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
attributed_to_visible_name = contributable_name_from_instance(attributed_to)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} attributed #{link_to attributed_what_visible_name, attributed_what_path} #{model_visible_name(attributed_what.class.to_s)} to #{link_to attributed_to_visible_name, attributed_to_path} #{model_visible_name(attributed_to.class.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} attributed #{link_to attributed_what_visible_name, attributed_what_path} #{model_visible_name(attributed_what.class.to_s)} to #{link_to attributed_to_visible_name, 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
@@ -1727,14 +1734,14 @@
object, object_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
object_visible_name = contributable_name_from_instance(object)
- rtn << [timestamp, "#{name(log_entry.culprit_id)} tagged #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} with \"#{link_to tag.name, tag_path(tag.id)}\"."]
+ rtn << [timestamp, "#{culprit_link} tagged #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)} with \"#{link_to tag.name, tag_path(tag.id)}\"."]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing tagging / tag / object
end
end
when "PictureSelection"
- rtn << [timestamp, "#{name(log_entry.culprit_id)} selected a new profile picture #{link_to image_tag(avatar_url(log_entry.referenced_id, 50)), user_path(log_entry.culprit_id)}."]
+ rtn << [timestamp, "#{culprit_link} selected a new profile picture #{link_to image_tag(avatar_url(log_entry.referenced_id, 50)), user_path(log_entry.culprit_id)}."]
when "User"
case action