comparison antispam/utils.py @ 780:feafa1c3d356

Issue #61, delete user photos when deactivating spammers.
author Brian Neal <bgneal@gmail.com>
date Sun, 04 May 2014 15:18:26 -0500
parents 08d905e38a86
children 9e803323a0d0
comparison
equal deleted inserted replaced
779:c740e097458f 780:feafa1c3d356
9 from antispam.models import SpamPhrase 9 from antispam.models import SpamPhrase
10 from core.functions import email_admins 10 from core.functions import email_admins
11 from bio.models import STA_SUSPENDED, STA_SPAMMER 11 from bio.models import STA_SUSPENDED, STA_SPAMMER
12 from comments.models import Comment 12 from comments.models import Comment
13 from forums.tools import delete_user_posts 13 from forums.tools import delete_user_posts
14 from user_photos.s3 import delete_photos
14 15
15 16
16 def contains_spam(s): 17 def contains_spam(s):
17 """This function returns True if the supplied string s contains any spam 18 """This function returns True if the supplied string s contains any spam
18 phrases and False otherwise. 19 phrases and False otherwise.
94 user.website_profiles.all().delete() 95 user.website_profiles.all().delete()
95 96
96 # delete shouts 97 # delete shouts
97 user.shout_set.all().delete() 98 user.shout_set.all().delete()
98 99
100 # delete any uploaded photos
101 photos = user.uploaded_photos.all()
102 if len(photos):
103 delete_photos(photos)
104 photos.delete()
105
99 logging.info("User deactivated for spam: %s", user.username) 106 logging.info("User deactivated for spam: %s", user.username)
100 107
101 108
102 def _get_spam_phrases(): 109 def _get_spam_phrases():
103 """ 110 """