From cc62cf46af63cb65afb8e322a5ebb86462d6fb45 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 27 May 2012 14:36:32 -0400 Subject: 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 --- askbot/doc/source/changelog.rst | 5 +++++ askbot/models/__init__.py | 8 ++++++++ askbot/models/question.py | 14 ++++++++++++++ askbot/skins/default/templates/macros.html | 2 +- askbot/skins/default/templates/user_profile/user_info.html | 4 ++-- .../default/templates/user_profile/user_moderate.html | 2 +- askbot/views/users.py | 2 +- 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()) %} {{ macros.timeago(view_user.last_seen) }} {% endif %} - {% if view_user.website %} + {% if view_user.website and (not view_user.is_blocked()) %} {% trans %}website{% endtrans %} {{ macros.user_website_link(view_user, max_display_length = 30) }} @@ -95,7 +95,7 @@
- {% if view_user.about %} + {% if view_user.about and (not view_user.is_blocked()) %} {{view_user.about|linebreaks}} {% endif %}
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 -- cgit v1.2.3-1-g7c22