Mercurial > public > sg101
diff gpp/forums/forms.py @ 96:93d9e74a471e
Forums: added forum post counts for each user in the user profile.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 13 Sep 2009 18:43:08 +0000 |
parents | 23035afdeae8 |
children | eb9f99382476 |
line wrap: on
line diff
--- a/gpp/forums/forms.py Sun Sep 13 18:05:18 2009 +0000 +++ b/gpp/forums/forms.py Sun Sep 13 18:43:08 2009 +0000 @@ -8,6 +8,15 @@ from forums.models import Post +def bump_post_count(user): + """ + Increments the forum_post_count for the given user. + """ + profile = user.get_profile() + profile.forum_post_count += 1 + profile.save() + + class PostForm(forms.Form): """Form for creating a new post.""" body = forms.CharField(label='', widget=forms.Textarea) @@ -38,6 +47,7 @@ post = Post(topic=self.topic, user=user, body=self.cleaned_data['body'], user_ip=ip) post.save() + bump_post_count(user) return post @@ -70,4 +80,5 @@ user_ip=ip) post.save() + bump_post_count(user) return topic