From 95757b7ab8ad52783347c645dd3bdb37d09740e2 Mon Sep 17 00:00:00 2001 From: jordan Date: Sun, 21 Aug 2011 13:29:49 +0000 Subject: [PATCH] Improving the statement for the user subscriptions tab management, putting the settings tab in the else part of the construction, AttributeError was raised before if wrong tab parameter had been passed. Now there is no way to have NoneType response. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1162 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/users.py | 49 ++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/forum/views/users.py b/forum/views/users.py index 82e8175..9f039f7 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -398,7 +398,26 @@ def user_subscriptions(request, user, **kwargs): tab = request.GET.get('tab', "settings") - if tab == 'settings': + # Manage tab + if tab == 'manage': + manage_open = True + + auto = request.GET.get('auto', 'True') + if auto == 'True': + show_auto = True + subscriptions = QuestionSubscription.objects.filter(user=user).order_by('-last_view') + else: + show_auto = False + subscriptions = QuestionSubscription.objects.filter(user=user, auto_subscription=False).order_by('-last_view') + + return pagination.paginated(request, ('subscriptions', SubscriptionListPaginatorContext()), { + 'subscriptions':subscriptions, + 'view_user':user, + "auto":show_auto, + 'manage_open':manage_open, + }) + # Settings Tab and everything else + else: manage_open = False if request.method == 'POST': manage_open = False @@ -422,34 +441,6 @@ def user_subscriptions(request, user, **kwargs): 'manage_open':manage_open, } - elif tab == 'manage': - manage_open = True - - auto = request.GET.get('auto', 'True') - if auto == 'True': - show_auto = True - subscriptions = QuestionSubscription.objects.filter(user=user).order_by('-last_view') - else: - show_auto = False - subscriptions = QuestionSubscription.objects.filter(user=user, auto_subscription=False).order_by('-last_view') - - return pagination.paginated(request, ('subscriptions', SubscriptionListPaginatorContext()), { - 'subscriptions':subscriptions, - 'view_user':user, - "auto":show_auto, - 'manage_open':manage_open, - }) - - # else: - # todo: probably want to throw an error - # error = "error to throw" - - - - - - - @user_view('users/preferences.html', 'preferences', _('preferences'), _('preferences'), True, tabbed=False) def user_preferences(request, user, **kwargs): if request.POST: -- 2.45.1