GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Adds basic social networking capabilities to your existing application, including users, blogs, photos, clippings, favorites, and more.
Homepage: http://www.communityengine.org
Clone URL: git://github.com/bborn/communityengine.git
bug fixes related to activities
bborn (author)
Thu May 29 17:04:51 -0700 2008
commit  8e7d44ab742486644951fc66d76b99ee2256c84c
tree    07d802c4582bbdebd38a61cdbd03df409bebf63d
parent  4c9c0e1c0ab3337a18a37937763aecb9255d8019
...
22
23
24
 
 
 
 
 
 
 
 
 
 
25
26
27
...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -22,6 +22,16 @@ class Post < ActiveRecord::Base
0
 
0
   before_save :transform_post
0
   before_validation :set_published_at
0
+
0
+ after_save do |post|
0
+ activity = Activity.find_by_item_type_and_item_id('Post', post.id)
0
+ if post.is_live? && !activity
0
+ post.create_activity_from_self
0
+ elsif post.is_draft? && activity
0
+ activity.destroy
0
+ end
0
+ end
0
+
0
   attr_accessor :invalid_emails
0
   
0
   def self.find_related_to(post, options = {})
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 %dl{:class => (activity.item_type && activity.item_type.humanize.downcase) }
0
   %dt
0
- =time_ago_in_words_or_date(activity.published_at || activity.created_at)
0
+ =time_ago_in_words_or_date(activity.created_at)
0
   %dd
0
     =link_to activity.user.login.capitalize, user_path(activity.user.login_slug)
0
     - if activity.item
...
33
34
35
 
36
37
...
33
34
35
36
37
38
0
@@ -33,5 +33,6 @@
0
         = f.select(:published_as, [['Published', 'live'], ['Draft', 'draft']])
0
         %p
0
           = submit_tag "Update"
0
+ %p=link_to 'Delete?', user_post_path(current_user, @post), :method => :delete, :confirm => "Are you sure you want to delete this post?"
0
 
0
   = observe_field "post_category_id", {:url => {:action => 'category_tips_update'}, :with => "post_category_id", :update => "category_tips", :complete => visual_effect(:highlight, "category_tips", :duration => 0.5)}
...
1
2
3
4
 
 
 
 
 
5
6
7
...
1
 
 
 
2
3
4
5
6
7
8
9
0
@@ -1,7 +1,9 @@
0
 .yui-b.sidebar
0
- %ul.checks
0
- %li=link_to 'View my blog', user_posts_path(current_user)
0
- %li=link_to 'View my profile', user_path(current_user)
0
+ .box
0
+ %h3 Links
0
+ %ul.checks
0
+ %li=link_to 'View my blog', user_posts_path(current_user)
0
+ %li=link_to 'New post', new_user_post_path(current_user)
0
 
0
 #yui-main
0
   .yui-b
...
26
27
28
 
29
30
31
...
26
27
28
29
30
31
32
0
@@ -26,6 +26,7 @@ module ActivityTracker # :nodoc:
0
           end
0
         end
0
 
0
+ has_many :activities, :as => :item, :dependent => :destroy
0
         class_inheritable_accessor :activity_options
0
         include InstanceMethods
0
       end
...
65
66
67
 
 
 
 
 
 
 
 
 
 
 
68
69
70
...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
0
@@ -65,6 +65,17 @@ class PostTest < Test::Unit::TestCase
0
     end
0
   end
0
   
0
+ def test_should_delete_post_activity
0
+ post = Post.new(:title => 'testing activity tracking', :raw_post => 'will this work?', :published_as => 'live')
0
+ post.user = users(:quentin)
0
+ post.save!
0
+
0
+ assert_difference Activity, :count, -1 do
0
+ post.destroy
0
+ end
0
+ end
0
+
0
+
0
   # def test_link_for_rss
0
   # assert_equal posts(:funny_post).link_for_rss, "http://localhost:3000/quentin/posts/1-This-is-really-good-stuff"
0
   # end

Comments

    No one has commented yet.