summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-27 14:36:32 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-27 14:36:32 -0400
commitcc62cf46af63cb65afb8e322a5ebb86462d6fb45 (patch)
tree7f51a42997ab468f6219d0031e9bdec3331c41b8
parent1d032505979fc8241e19af5f7ec0167781def5fd (diff)
downloadaskbot-cc62cf46af63cb65afb8e322a5ebb86462d6fb45.tar.gz
askbot-cc62cf46af63cb65afb8e322a5ebb86462d6fb45.tar.bz2
askbot-cc62cf46af63cb65afb8e322a5ebb86462d6fb45.zip
hide website url and the "about" sections of the blocked user profiles, blocked users are not present in the list of the users either, website url does not show in post signatures
-rw-r--r--askbot/doc/source/changelog.rst5
-rw-r--r--askbot/models/__init__.py8
-rw-r--r--askbot/models/question.py14
-rw-r--r--askbot/skins/default/templates/macros.html2
-rw-r--r--askbot/skins/default/templates/user_profile/user_info.html4
-rw-r--r--askbot/skins/default/templates/user_profile/user_moderate.html2
-rw-r--r--askbot/views/users.py2
7 files changed, 32 insertions, 5 deletions
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst
index e005e019..e9c0da6a 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -1,6 +1,11 @@
Changes in Askbot
=================
+In development
+---------------------
+* Hide "website" and "about" section of the blocked user profiles
+ to help prevent user profile spam. (Evgeny)
+
0.7.43 (May 14, 2012)
---------------------
* User groups (Evgeny)
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 5e41a07a..27bc98c2 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -1841,6 +1841,14 @@ def user_set_status(self, new_status):
if self.is_administrator():
self.remove_admin_status()
+ #when toggling between blocked and non-blocked status
+ #we need to invalidate question page caches, b/c they contain
+ #user's url, which must be hidden in the blocked state
+ if 'b' in (new_status, self.status) and new_status != self.status:
+ threads = Thread.objects.get_for_user(self)
+ for thread in threads:
+ thread.invalidate_cached_post_data()
+
self.status = new_status
self.save()
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 7d1c3758..dafe7ab0 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -357,6 +357,20 @@ class ThreadManager(models.Manager):
contributors = User.objects.filter(id__in=u_id).order_by('avatar_type', '?')[:avatar_limit]
return contributors
+ def get_for_user(self, user):
+ """returns threads where a given user had participated"""
+ post_ids = PostRevision.objects.filter(
+ author = user
+ ).values_list(
+ 'post_id', flat = True
+ ).distinct()
+ thread_ids = Post.objects.filter(
+ id__in = post_ids
+ ).values_list(
+ 'thread_id', flat = True
+ ).distinct()
+ return self.filter(id__in = thread_ids)
+
class Thread(models.Model):
SUMMARY_CACHE_KEY_TPL = 'thread-question-summary-%d'
diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html
index 4bae1e45..c8dc245f 100644
--- a/askbot/skins/default/templates/macros.html
+++ b/askbot/skins/default/templates/macros.html
@@ -578,7 +578,7 @@ answer {% if answer.accepted() %}accepted-answer{% endif %} {% if answer.author_
{%- endmacro -%}
{%- macro user_website_link(user, max_display_length=25) -%}
- {% if user.website %}
+ {% if user.website and (not user.is_blocked()) %}
<a
href="{{user.website}}"
title="{% trans username=user.username|escape, url=user.website %}{{username}}'s website is {{url}}{% endtrans %}"
diff --git a/askbot/skins/default/templates/user_profile/user_info.html b/askbot/skins/default/templates/user_profile/user_info.html
index 18e74464..ad460dbc 100644
--- a/askbot/skins/default/templates/user_profile/user_info.html
+++ b/askbot/skins/default/templates/user_profile/user_info.html
@@ -66,7 +66,7 @@
<td><strong title="{{ view_user.last_seen }}">{{ macros.timeago(view_user.last_seen) }}</strong></td>
</tr>
{% endif %}
- {% if view_user.website %}
+ {% if view_user.website and (not view_user.is_blocked()) %}
<tr>
<td>{% trans %}website{% endtrans %}</td>
<td>{{ macros.user_website_link(view_user, max_display_length = 30) }}</td>
@@ -95,7 +95,7 @@
</td>
<td width="380">
<div class="user-about">
- {% if view_user.about %}
+ {% if view_user.about and (not view_user.is_blocked()) %}
{{view_user.about|linebreaks}}
{% endif %}
</div>
diff --git a/askbot/skins/default/templates/user_profile/user_moderate.html b/askbot/skins/default/templates/user_profile/user_moderate.html
index 048f35b4..347ec3af 100644
--- a/askbot/skins/default/templates/user_profile/user_moderate.html
+++ b/askbot/skins/default/templates/user_profile/user_moderate.html
@@ -83,7 +83,7 @@
$('#id_user_status_info').html("{% trans %}Suspended users can only edit or delete their own posts.{% endtrans %}");
$('#id_user_status_info').show('slow');
} else if (optionValue == "b"){
- $('#id_user_status_info').html("{% trans %}Blocked users can only login and send feedback to the site administrators.{% endtrans %}");
+ $('#id_user_status_info').html("{% trans %}Blocked users can only login and send feedback to the site administrators, their url and profile will also be hidden.{% endtrans %}");
$('#id_user_status_info').show('slow');
} else {
$('#id_user_status_info').hide('slow');
diff --git a/askbot/views/users.py b/askbot/views/users.py
index ef0aea57..c17ddd43 100644
--- a/askbot/views/users.py
+++ b/askbot/views/users.py
@@ -57,7 +57,7 @@ def owner_or_moderator_required(f):
def users(request, by_group = False, group_id = None, group_slug = None):
"""Users view, including listing of users by group"""
- users = models.User.objects.all()
+ users = models.User.objects.exclude(status = 'b')
group = None
group_email_moderation_enabled = False
user_can_join_group = False