[PATCH 1 of 2] When updating user accounts, use all-inclusive Managers, not filtered sets

2 views
Skip to first unread message

Ben Jackson

unread,
Dec 3, 2009, 12:16:08 AM12/3/09
to byteflow-hackers
# HG changeset patch
# User Ben Jackson <b...@ben.com>
# Date 1259815440 28800
# Node ID 3e328d99dbf6b332ecd52a76cb171cf96128e1a6
# Parent 640229937ff271796f03e83c5e773890a38424de
When updating user accounts, use all-inclusive Managers, not filtered sets.

Since users are a global concept they should apply across sites. They
should also be updated even in invisible objects (unapproved comments,
draft posts, future posts, etc).

diff -r 640229937ff2 -r 3e328d99dbf6 apps/accounts/forms.py
--- a/apps/accounts/forms.py Wed Dec 02 20:25:55 2009 -0800
+++ b/apps/accounts/forms.py Wed Dec 02 20:44:00 2009 -0800
@@ -149,9 +149,9 @@
newuser = authenticate(email=self.cleaned_data['email'], password=self.cleaned_data['password'])
olduser = self.request.user
from blog.models import Post
- Post.objects.filter(author=olduser).update(author=newuser)
+ Post.plain_manager.filter(author=olduser).update(author=newuser)
from discussion.models import CommentNode
- CommentNode.objects.filter(user=olduser).update(user=newuser)
+ CommentNode.all_objects.filter(user=olduser).update(user=newuser)
from watchlist.models import Subscription
Subscription.objects.filter(user=olduser).update(user=newuser)
from openidconsumer.models import UserAssociation

Reply all
Reply to author
Forward
0 new messages