Hi,
a while ago I asked in this mailing list how to delete the accounts of 'fake
users' or spam accounts in a public reviewboard instance.
Today I managed to do it via a little script that can be run from a python
console. Maybe it can help some of you to do the same. The script walks over
all users in the database and deletes all users who have never done anything
else in reviewboard but registering and visiting a review.
So every user who is associated to at least one ReviewComment or some other
meaningful object in the database is spared.
Here is the script:
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.db.models.query_utils import CollectedObjects
spam = 0
ham = 0
for user in User.objects.all():
print "User: %s ..." % user,
isactive = False
seen_objs = None
seen_objs = CollectedObjects(seen_objs)
user._collect_sub_objects(seen_objs)
for obj in seen_objs.keys():
if (obj.__name__ != "Profile") and (obj.__name__ != "ReviewRequestVisit"):
isactive = True
break
if (isactive):
print "Active (found associated %s)" % obj
ham = ham + 1
else:
spam = spam + 1
#user.delete()
print "DELETED"
print "Total HAM %d" % ham
print "Total SPAM %d" % spam
You can simply run it by typing
rb-site manage /path/to/site shell
and then pasting the script above. (make sure you have a backup of you
database!)
Cheers,
David
PS: note that I commented the line that actually does the deletion, so you can
do a dry run before
--
Want to help the Review Board project? Donate today at
http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/reviewboard?hl=en