Revision 1978
Author alekses6
Date 2008-11-17 12:45:33 -0500 (Mon, 17 Nov 2008)
Log Message
News generation. Added workflow type to all news entries containing info
about workflows.
Modified Paths
• branches/event_logging/app/helpers/application_helper.rb
Diff
Modified: branches/event_logging/app/helpers/application_helper.rb (1977
=> 1978)
--- branches/event_logging/app/helpers/application_helper.rb 2008-11-17
16:33:47 UTC (rev 1977)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-11-17
17:45:33 UTC (rev 1978)
@@ -954,7 +954,7 @@
end
# NB! used in news generation
- def model_visible_name(model_name)
+ def model_visible_name(model_name, add_type_if_workflow=false,
obj_instance=nil)
case model_name
when "Blob"
return "File"
@@ -962,6 +962,12 @@
return "Group"
when "GroupAnnouncement"
return "group announcement"
+ when "Workflow"
+ type = ""
+ if add_type_if_workflow && obj_instance
+ type += "[" + obj_instance.type_display_name + "] "
+ end
+ return type + "Workflow"
else
return model_name
end
@@ -1804,6 +1810,7 @@
wf_version =
Workflow::Version.find(log_entry.activity_loggable_id, :include =>
:workflow)
wf_version_number = wf_version.version
main_wf = wf_version.workflow
+ wf_type = "[#{main_wf.type_display_name}]"
authorized = my_event || main_wf.authorized?("view",
current_viewer)
return nil unless authorized
@@ -1818,13 +1825,13 @@
if authorized
if action == "create" && wf_version.version == 1
# new workflow created
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>created</span> the #{link_to
workflow_visible_name, workflow_path} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>created</span> the #{link_to
workflow_visible_name, workflow_path} #{wf_type} Workflow."]
elsif action == "create"
# added new version for existing workflow
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> version #{wf_version_number} of the
#{link_to workflow_visible_name, workflow_path} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> version #{wf_version_number} of the
#{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow."]
elsif action == "update"
# updated an existing version
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>updated</span> version #{wf_version_number} of
the #{link_to workflow_visible_name, workflow_path} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>updated</span> version #{wf_version_number} of
the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow."]
end
end
rescue ActiveRecord::RecordNotFound
@@ -1880,7 +1887,7 @@
authorized = false unless my_event ||
object.authorized?("view", current_viewer)
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to object_visible_name,
object_path} #{model_visible_name(object.class.to_s)} to #{pack_link}
Pack."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to object_visible_name,
object_path} #{model_visible_name(object.class.to_s, true, object)} to
#{pack_link} Pack."]
end
else
# ..and check if external link can still be found
@@ -2084,7 +2091,7 @@
items_shared_with_this_permission.each do |item|
object, path =
evaluate_object_instance_and_path(item.contributable_type,
item.contributable_id)
object_visible_name =
contributable_name_from_instance(object)
- shared_what_links_arr << (link_to(object_visible_name,
path) + " " + model_visible_name(object.class.to_s))
+ shared_what_links_arr << (link_to(object_visible_name,
path) + " " + model_visible_name(object.class.to_s, true, object))
end
if authorized
@@ -2108,7 +2115,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>rated</span> #{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} <span
class='news_feed_action'>rated</span> #{link_to object_visible_name,
object_path} #{model_visible_name(log_entry.referenced_type.to_s, true,
object)} #{rating.rating} out of 5."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
rating / object
@@ -2131,7 +2138,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to object_visible_name,
object_path} #{model_visible_name(log_entry.referenced_type.to_s)} to
their #{link_to "favourites", user_path(log_entry.culprit_id) +
"/favourites"}."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to object_visible_name,
object_path} #{model_visible_name(log_entry.referenced_type.to_s, true,
object)} to their #{link_to "favourites", user_path(log_entry.culprit_id)
+ "/favourites"}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
bookmark / object
@@ -2150,7 +2157,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- 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)}."]
+ 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, true, object)}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
comment / object
@@ -2178,7 +2185,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} #{link_to_unless
reviewed_link.nil?, (reviewed_link.nil? ? "<span
class='news_feed_action'>reviewed</span>" : "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_link.nil? ? "<span
class='news_feed_action'>reviewed</span>" : "reviewed"), reviewed_link}
#{link_to object_visible_name, object_path}
#{model_visible_name(log_entry.referenced_type.to_s, true,
object)}#{review_title_link}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
review / object
@@ -2214,7 +2221,7 @@
end
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>credited</span> #{credited_whom} for #{link_to
object_visible_name, object_path}
#{model_visible_name(object.class.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>credited</span> #{credited_whom} for #{link_to
object_visible_name, object_path} #{model_visible_name(object.class.to_s,
true, object)}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
creditation / object
@@ -2239,7 +2246,7 @@
authorized = ( my_event || attributed_to.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>attributed</span> #{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} <span
class='news_feed_action'>attributed</span> #{link_to
attributed_what_visible_name, attributed_what_path}
#{model_visible_name(attributed_what.class.to_s, true, attributed_what)}
to #{link_to attributed_to_visible_name, attributed_to_path}
#{model_visible_name(attributed_to.class.to_s, true, attributed_to)}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
creditation / object
@@ -2258,7 +2265,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>tagged</span> #{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} <span
class='news_feed_action'>tagged</span> #{link_to object_visible_name,
object_path} #{model_visible_name(log_entry.referenced_type.to_s, true,
object)} with \"#{link_to tag.name, tag_path(tag.id)}\"."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
tagging / tag / object
@@ -2280,7 +2287,7 @@
authorized = ( my_event || object.authorized?("view",
current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to "citation",
workflow_citation_path(object.id, citation.id)} for #{link_to
object_visible_name, object_path}
#{model_visible_name(log_entry.referenced_type.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} <span
class='news_feed_action'>added</span> #{link_to "citation",
workflow_citation_path(object.id, citation.id)} for #{link_to
object_visible_name, object_path}
#{model_visible_name(log_entry.referenced_type.to_s, true, object)}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing
citation / cited item