summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-10-11 20:36:25 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-10-11 20:36:25 -0600
commitef417420575cdc4a473ae41203736fe21b7cb5de (patch)
tree50111a9d9faffb9340b23b9884052936130b9c77
parent0a738f2510686d298af69077ac70da31d654b30f (diff)
parent18de3b9d5d8fadff635867d1b3cd635c23ff0b51 (diff)
downloadaskbot-ef417420575cdc4a473ae41203736fe21b7cb5de.tar.gz
askbot-ef417420575cdc4a473ae41203736fe21b7cb5de.tar.bz2
askbot-ef417420575cdc4a473ae41203736fe21b7cb5de.zip
Merge branch 'master' of github.com:ASKBOT/askbot-devel
-rw-r--r--askbot/media/style/style.less1
-rw-r--r--askbot/tests/__init__.py1
-rw-r--r--askbot/tests/user_views_tests.py39
-rw-r--r--askbot/views/users.py4
4 files changed, 43 insertions, 2 deletions
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{
diff --git a/askbot/tests/__init__.py b/askbot/tests/__init__.py
index 96ba2045..59db8f67 100644
--- a/askbot/tests/__init__.py
+++ b/askbot/tests/__init__.py
@@ -19,5 +19,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 c2f11328..707f4e14 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