summaryrefslogtreecommitdiffstats
path: root/askbot/views/users.py
diff options
context:
space:
mode:
Diffstat (limited to 'askbot/views/users.py')
-rw-r--r--askbot/views/users.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/askbot/views/users.py b/askbot/views/users.py
index ef0aea57..19613838 100644
--- a/askbot/views/users.py
+++ b/askbot/views/users.py
@@ -41,6 +41,7 @@ from askbot.skins.loaders import render_into_skin
from askbot.templatetags import extra_tags
from askbot.search.state_manager import SearchState
from askbot.utils import url_utils
+from askbot.utils.loading import load_module
def owner_or_moderator_required(f):
@functools.wraps(f)
@@ -57,7 +58,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
@@ -654,7 +655,8 @@ def user_responses(request, user, context):
#3) "package" data for the output
response_list = list()
for memo in memo_set:
- #a monster query chain below
+ if memo.activity.content_object is None:
+ continue#a temp plug due to bug in the comment deletion
response = {
'id': memo.id,
'timestamp': memo.activity.active_at,
@@ -840,6 +842,24 @@ def user_email_subscriptions(request, user, context):
request
)
+@csrf.csrf_protect
+def user_custom_tab(request, user, context):
+ """works only if `ASKBOT_CUSTOM_USER_PROFILE_TAB`
+ setting in the ``settings.py`` is properly configured"""
+ tab_settings = django_settings.ASKBOT_CUSTOM_USER_PROFILE_TAB
+ module_path = tab_settings['CONTENT_GENERATOR']
+ content_generator = load_module(module_path)
+
+ page_title = _('profile - %(section)s') % \
+ {'section': tab_settings['NAME']}
+
+ context.update({
+ 'custom_tab_content': content_generator(request, user),
+ 'tab_name': tab_settings['SLUG'],
+ 'page_title': page_title
+ })
+ return render_into_skin('user_profile/custom_tab.html', context, request)
+
USER_VIEW_CALL_TABLE = {
'stats': user_stats,
'recent': user_recent,
@@ -851,6 +871,12 @@ USER_VIEW_CALL_TABLE = {
'email_subscriptions': user_email_subscriptions,
'moderation': user_moderate,
}
+
+CUSTOM_TAB = getattr(django_settings, 'ASKBOT_CUSTOM_USER_PROFILE_TAB', None)
+if CUSTOM_TAB:
+ CUSTOM_SLUG = CUSTOM_TAB['SLUG']
+ USER_VIEW_CALL_TABLE[CUSTOM_SLUG] = user_custom_tab
+
#todo: rename this function - variable named user is everywhere
def user(request, id, slug=None, tab_name=None):
"""Main user view function that works as a switchboard
@@ -897,6 +923,9 @@ def user(request, id, slug=None, tab_name=None):
'search_state': search_state,
'user_follow_feature_on': ('followit' in django_settings.INSTALLED_APPS),
}
+ if CUSTOM_TAB:
+ context['custom_tab_name'] = CUSTOM_TAB['NAME']
+ context['custom_tab_slug'] = CUSTOM_TAB['SLUG']
return user_view_func(request, profile_owner, context)
@csrf.csrf_exempt