comparison gpp/forums/tools.py @ 390:e0523e17ea43

Fixing #175; add an auto-subscribe and auto-favorite forum topic feature. Added 2 flags to the user profile. Added 2 functions that are called on the post post-save signal that auto-favorite and auto-subscribe the post creator if they have requested this service.
author Brian Neal <bgneal@gmail.com>
date Mon, 21 Mar 2011 00:39:52 +0000
parents d1b11096595b
children
comparison
equal deleted inserted replaced
389:3fa61786abf1 390:e0523e17ea43
104 post = Post(topic=topic, 104 post = Post(topic=topic,
105 user=user, 105 user=user,
106 body=post_body, 106 body=post_body,
107 user_ip=ip) 107 user_ip=ip)
108 post.save() 108 post.save()
109
110
111 def auto_favorite(post):
112 """
113 Given a newly created post, perform an auto-favorite action if the post
114 creator has that option set in their profile.
115
116 """
117 profile = post.user.get_profile()
118 if profile.auto_favorite:
119 post.topic.bookmarkers.add(post.user)
120
121
122 def auto_subscribe(post):
123 """
124 Given a newly created post, perform an auto-subscribe action if the post
125 creator has that option set in their profile.
126
127 """
128 profile = post.user.get_profile()
129 if profile.auto_subscribe:
130 post.topic.subscribers.add(post.user)