Mercurial > public > sg101
comparison forums/views/spam.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 | ee87ea74d46b |
children | e932f2ecd4a7 |
comparison
equal
deleted
inserted
replaced
788:84aa49497718 | 789:9e803323a0d0 |
---|---|
27 | 27 |
28 | 28 |
29 def promote_stranger(user): | 29 def promote_stranger(user): |
30 """This function upgrades the user from stranger status to a regular user. | 30 """This function upgrades the user from stranger status to a regular user. |
31 """ | 31 """ |
32 profile = user.get_profile() | 32 profile = user.profile |
33 if user.is_active and profile.status == bio.models.STA_STRANGER: | 33 if user.is_active and profile.status == bio.models.STA_STRANGER: |
34 profile.status = bio.models.STA_ACTIVE | 34 profile.status = bio.models.STA_ACTIVE |
35 profile.status_date = datetime.datetime.now() | 35 profile.status_date = datetime.datetime.now() |
36 profile.save(content_update=False) | 36 profile.save(content_update=False) |
37 | 37 |
40 def spammer(request, post_id): | 40 def spammer(request, post_id): |
41 """This view allows moderators to deactivate spammer accounts.""" | 41 """This view allows moderators to deactivate spammer accounts.""" |
42 | 42 |
43 post = get_object_or_404(Post.objects.select_related(), pk=post_id) | 43 post = get_object_or_404(Post.objects.select_related(), pk=post_id) |
44 poster = post.user | 44 poster = post.user |
45 poster_profile = poster.get_profile() | 45 poster_profile = poster.profile |
46 | 46 |
47 can_moderate = perms.can_moderate(post.topic.forum, request.user) | 47 can_moderate = perms.can_moderate(post.topic.forum, request.user) |
48 can_deactivate = (poster_profile.status == bio.models.STA_STRANGER and not | 48 can_deactivate = (poster_profile.status == bio.models.STA_STRANGER and not |
49 poster.is_superuser) | 49 poster.is_superuser) |
50 | 50 |
78 def spammer_nailed(request, spammer_id): | 78 def spammer_nailed(request, spammer_id): |
79 """This view presents a confirmation screen that the spammer has been | 79 """This view presents a confirmation screen that the spammer has been |
80 deactivated. | 80 deactivated. |
81 """ | 81 """ |
82 user = get_object_or_404(User, pk=spammer_id) | 82 user = get_object_or_404(User, pk=spammer_id) |
83 profile = user.get_profile() | 83 profile = user.profile |
84 | 84 |
85 success = not user.is_active and profile.status == bio.models.STA_SPAMMER | 85 success = not user.is_active and profile.status == bio.models.STA_SPAMMER |
86 | 86 |
87 return render_to_response('forums/spammer_nailed.html', { | 87 return render_to_response('forums/spammer_nailed.html', { |
88 'spammer': user, | 88 'spammer': user, |
96 """This view allows a forum moderator or super user to promote a user from | 96 """This view allows a forum moderator or super user to promote a user from |
97 stranger status to regular user. | 97 stranger status to regular user. |
98 """ | 98 """ |
99 post = get_object_or_404(Post.objects.select_related(), pk=post_id) | 99 post = get_object_or_404(Post.objects.select_related(), pk=post_id) |
100 poster = post.user | 100 poster = post.user |
101 poster_profile = poster.get_profile() | 101 poster_profile = poster.profile |
102 | 102 |
103 can_moderate = perms.can_moderate(post.topic.forum, request.user) | 103 can_moderate = perms.can_moderate(post.topic.forum, request.user) |
104 can_promote = poster_profile.status == bio.models.STA_STRANGER | 104 can_promote = poster_profile.status == bio.models.STA_STRANGER |
105 | 105 |
106 if request.method == "POST" and can_moderate and can_promote: | 106 if request.method == "POST" and can_moderate and can_promote: |