myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [1906] branches/event_logging/app/helpers/applica


From: noreply
Subject: [myexperiment-hackers] [1906] branches/event_logging/app/helpers/application_helper.rb: News.
Date: Thu, 30 Oct 2008 11:01:53 -0400 (EDT)

Revision
1906
Author
alekses6
Date
2008-10-30 11:01:53 -0400 (Thu, 30 Oct 2008)

Log Message

News. Minor text formatting.

Bug-fix: user joining myExperiment news entry now checks that user is still there.

Bug-fix: new user profile picture in the news now has a proper tooltip text (user's name).

Modified Paths

Diff

Modified: branches/event_logging/app/helpers/application_helper.rb (1905 => 1906)


--- branches/event_logging/app/helpers/application_helper.rb	2008-10-30 14:17:35 UTC (rev 1905)
+++ branches/event_logging/app/helpers/application_helper.rb	2008-10-30 15:01:53 UTC (rev 1906)
@@ -1530,11 +1530,16 @@
     # (further checks for other related objects are carried out in the respective sections for every ActivityLoggable type)
     unless ["Membership", "User"].include? loggable_type
       # 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
+      # if culprit is not found by ActiveRecord - exception will be thrown 
       # -> news item not to be shown then
-      culprit_link = name(log_entry.culprit_id)
-      my_event = (log_entry.culprit_id == current_viewer.id)
-      return nil if culprit_link.nil?
+      begin
+        culprit = User.find(:first, :select => "id, name", :conditions => ["id = ?", log_entry.culprit_id])
+        culprit_link = name(culprit)
+        my_event = (log_entry.culprit_id == current_viewer.id)
+      rescue ActiveRecord::RecordNotFound
+        # culprit wasn't found - skip this news entry
+        return nil
+      end
     end
     
     
@@ -1596,7 +1601,7 @@
                
                # if allowed to see the pack, no further checks required as anyone can see external items
                if authorized
-                 rtn << [timestamp, "#{culprit_link} added external link to #{pack_link} Pack: #{link_to remote_entry.title, remote_entry.uri, :title => tooltip_title_attrib(h(remote_entry.uri))}."]
+                 rtn << [timestamp, "#{culprit_link} added an external link to #{pack_link} Pack: #{link_to remote_entry.title, remote_entry.uri, :title => tooltip_title_attrib(h(remote_entry.uri))}."]
                end
              end
            rescue ActiveRecord::RecordNotFound
@@ -1993,7 +1998,7 @@
       when "PictureSelection"
         # TODO: how to check that picture selection is still valid?
         # anyone can see picture selections of others (news only generated for friends / user's networks' members anyway)
-        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)}."]
+        rtn << [timestamp, "#{culprit_link} selected a new profile picture #{link_to image_tag(avatar_url(log_entry.referenced_id, 50), :alt => h(culprit.name)), user_path(log_entry.culprit_id)}."]
       
       when "Profile"
         case action
@@ -2002,15 +2007,19 @@
           when "update"
             # only friends of the user will see this event
             if my_event || (logged_in? && current_viewer.friend?(log_entry.culprit_id))
-              rtn << [timestamp, "#{culprit_link} has updated their #{link_to "profile", user_path(log_entry.culprit_id)}"]
+              rtn << [timestamp, "#{culprit_link} has updated their #{link_to "profile", user_path(log_entry.culprit_id)}."]
             end
         end
         
       when "User"
         case action
           when "activate"
-            # anyone can see new users joining myExperiment
-            rtn << [timestamp, "#{name(log_entry.activity_loggable.id)} joined #{link_to "myExperiment", "/"}."]
+            # anyone can see new users joining myExperiment - just need to check that user still exists
+            # (if "name()" helper returns NIL -> user not found)
+            user_link = name(log_entry.activity_loggable_id)
+            return nil if user_link.nil?
+            
+            rtn << [timestamp, "#{user_link} joined #{link_to "myExperiment", "/"}."]
           when "update"
             # for now this event is not shown to anyone - event to the user themself,
             # partly because every time when user logs in "last seen" field is set, which

reply via email to

[Prev in Thread] Current Thread [Next in Thread]