comparison antispam/utils.py @ 789:9e803323a0d0

Removing AUTH_PROFILE_MODULE and get_profile().
author Brian Neal <bgneal@gmail.com>
date Fri, 23 May 2014 15:10:11 -0500
parents feafa1c3d356
children
comparison
equal deleted inserted replaced
788:84aa49497718 789:9e803323a0d0
34 and returns True. If spam is not found, False is returned. 34 and returns True. If spam is not found, False is returned.
35 It is assumed that request.user is an authenticated user and thus has a 35 It is assumed that request.user is an authenticated user and thus has a
36 user profile. 36 user profile.
37 """ 37 """
38 user = request.user 38 user = request.user
39 if user.get_profile().is_stranger() and contains_spam(content): 39 if user.profile.is_stranger() and contains_spam(content):
40 40
41 ip = request.META.get('REMOTE_ADDR', "unknown") 41 ip = request.META.get('REMOTE_ADDR', "unknown")
42 42
43 msg = textwrap.dedent("""\ 43 msg = textwrap.dedent("""\
44 SPAM FILTER TRIPPED by %s 44 SPAM FILTER TRIPPED by %s
58 58
59 def suspend_user(user): 59 def suspend_user(user):
60 """This function marks the user as suspended.""" 60 """This function marks the user as suspended."""
61 user.is_active = False 61 user.is_active = False
62 user.save() 62 user.save()
63 profile = user.get_profile() 63 profile = user.profile
64 profile.status = STA_SUSPENDED 64 profile.status = STA_SUSPENDED
65 profile.status_date = datetime.datetime.now() 65 profile.status_date = datetime.datetime.now()
66 profile.save(content_update=False) 66 profile.save(content_update=False)
67 logging.info("User suspended: %s", user.username) 67 logging.info("User suspended: %s", user.username)
68 68
75 75
76 """ 76 """
77 user.is_active = False 77 user.is_active = False
78 user.save() 78 user.save()
79 79
80 profile = user.get_profile() 80 profile = user.profile
81 profile.status = STA_SPAMMER 81 profile.status = STA_SPAMMER
82 profile.status_date = datetime.datetime.now() 82 profile.status_date = datetime.datetime.now()
83 profile.reset() 83 profile.reset()
84 if profile.avatar: 84 if profile.avatar:
85 profile.avatar.delete(save=False) 85 profile.avatar.delete(save=False)