From 6c1fbbfefed9e3b684821fe8150c7e46e326f129 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 11 Oct 2012 13:40:22 -0400 Subject: small style fix for the user profile page --- askbot/media/style/style.less | 1 - 1 file changed, 1 deletion(-) diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less index 607261ce..a7d035ed 100644 --- a/askbot/media/style/style.less +++ b/askbot/media/style/style.less @@ -2695,7 +2695,6 @@ a:hover.medal { } .user-profile-page{ - font-size:13px; color:@info-text-dark; p{ -- cgit v1.2.3-1-g7c22 From 18de3b9d5d8fadff635867d1b3cd635c23ff0b51 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 11 Oct 2012 15:09:59 -0400 Subject: made owner_or_moderator_required decorator pass url parameters to the next url --- askbot/tests/__init__.py | 1 + askbot/tests/user_views_tests.py | 39 +++++++++++++++++++++++++++++++++++++++ askbot/views/users.py | 4 +++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 askbot/tests/user_views_tests.py diff --git a/askbot/tests/__init__.py b/askbot/tests/__init__.py index fcef288b..b9a8cd93 100644 --- a/askbot/tests/__init__.py +++ b/askbot/tests/__init__.py @@ -18,5 +18,6 @@ from askbot.tests.email_parsing_tests import * from askbot.tests.widget_tests import * from askbot.tests.category_tree_tests import CategoryTreeTests from askbot.tests.user_model_tests import UserModelTests +from askbot.tests.user_views_tests import * from askbot.tests.utils_tests import * from askbot.tests.view_context_tests import * diff --git a/askbot/tests/user_views_tests.py b/askbot/tests/user_views_tests.py new file mode 100644 index 00000000..489cf76a --- /dev/null +++ b/askbot/tests/user_views_tests.py @@ -0,0 +1,39 @@ +from askbot.tests.utils import AskbotTestCase +from askbot.views.users import owner_or_moderator_required +from django.contrib.auth.models import AnonymousUser +from django.core.urlresolvers import reverse +from django.http import HttpResponseRedirect +from mock import Mock +import urllib +import urlparse + +class UserViewsTests(AskbotTestCase): + + def test_owner_or_mod_required_passes_url_parameters(self): + @owner_or_moderator_required + def mock_view(request, user, context): + return None + + request = Mock(spec=('path', 'REQUEST', 'user')) + request.user = AnonymousUser() + request.REQUEST = {'abra': 'cadabra', 'foo': 'bar'} + request.path = '/some/path/' + user = self.create_user('user') + response = mock_view(request, user, {}) + self.assertEqual(isinstance(response, HttpResponseRedirect), True) + + url = response['location'] + parsed_url = urlparse.urlparse(url) + + self.assertEqual(parsed_url.path, reverse('user_signin')) + + next = dict(urlparse.parse_qsl(parsed_url.query))['next'] + next_url = urllib.unquote(next) + parsed_url = urlparse.urlparse(next_url) + + self.assertEqual(parsed_url.path, request.path) + + query = dict(urlparse.parse_qsl(parsed_url.query)) + self.assertEqual(set(query.keys()), set(['foo', 'abra'])) + self.assertEqual(set(query.values()), set(['bar', 'cadabra'])) + self.assertEqual(query['abra'], 'cadabra') diff --git a/askbot/views/users.py b/askbot/views/users.py index dbcbda5c..65862697 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -12,6 +12,7 @@ import functools import datetime import logging import operator +import urllib from django.db.models import Count from django.conf import settings as django_settings @@ -54,7 +55,8 @@ def owner_or_moderator_required(f): elif request.user.is_authenticated() and request.user.can_moderate_user(profile_owner): pass else: - params = '?next=%s' % request.path + next_url = request.path + '?' + urllib.urlencode(request.REQUEST) + params = '?next=%s' % urllib.quote(next_url) return HttpResponseRedirect(url_utils.get_login_url() + params) return f(request, profile_owner, context) return wrapped_func -- cgit v1.2.3-1-g7c22