summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2012-01-20 14:27:00 +0100
committerTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2012-01-20 14:27:00 +0100
commit0aec21fc8a1255aca61df55de10c6c6486ac243b (patch)
tree1a329fb310d2743dae5fbcb1ee139a7430d34463
parentd49ceb5b144356865d2566336f2e90283de9d029 (diff)
parentdaf0f1ccd75fa81c5e7065bc39df6a6ff792b02f (diff)
downloadaskbot-0aec21fc8a1255aca61df55de10c6c6486ac243b.tar.gz
askbot-0aec21fc8a1255aca61df55de10c6c6486ac243b.tar.bz2
askbot-0aec21fc8a1255aca61df55de10c6c6486ac243b.zip
Merge remote-tracking branch 'askbot/wikipost' into wikipost
-rw-r--r--askbot/context.py9
-rw-r--r--askbot/middleware/anon_user.py9
-rw-r--r--askbot/startup_procedures.py18
-rw-r--r--askbot/tests/page_load_tests.py11
-rw-r--r--askbot/user_messages/context_processors.py5
5 files changed, 47 insertions, 5 deletions
diff --git a/askbot/context.py b/askbot/context.py
index 41298fc1..ea10a890 100644
--- a/askbot/context.py
+++ b/askbot/context.py
@@ -13,6 +13,15 @@ from askbot.utils import url_utils
def application_settings(request):
"""The context processor function"""
+ if not request.path.startswith('/' + settings.ASKBOT_URL):
+ #todo: this is a really ugly hack, will only work
+ #when askbot is installed not at the home page.
+ #this will not work for the
+ #heavy modders of askbot, because their custom pages
+ #will not receive the askbot settings in the context
+ #to solve this properly we should probably explicitly
+ #add settings to the context per page
+ return {}
my_settings = askbot_settings.as_dict()
my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
diff --git a/askbot/middleware/anon_user.py b/askbot/middleware/anon_user.py
index 7cd9279d..956990e4 100644
--- a/askbot/middleware/anon_user.py
+++ b/askbot/middleware/anon_user.py
@@ -8,6 +8,7 @@ added to the :class:`AnonymousUser` so that user could be pickled.
Secondly, it sends greeting message to anonymous users.
"""
+from django.conf import settings as django_settings
from askbot.user_messages import create_message, get_and_delete_messages
from askbot.conf import settings as askbot_settings
@@ -42,6 +43,10 @@ class ConnectToSessionMessagesMiddleware(object):
"""Enables anonymous users to receive messages
the same way as authenticated users, and sets
the anonymous user greeting, if it should be shown"""
+ if not request.path.startswith('/' + django_settings.ASKBOT_URL):
+ #todo: a hack, for real we need to remove this middleware
+ #and switch to the new-style session messages
+ return
if request.user.is_anonymous():
#1) Attach the ability to receive messages
#plug on deepcopy which may be called by django db "driver"
@@ -63,6 +68,10 @@ class ConnectToSessionMessagesMiddleware(object):
"""Adds the ``'askbot_visitor'``key to cookie if user ever
authenticates so that the anonymous user message won't
be shown after the user logs out"""
+ if not request.path.startswith('/' + django_settings.ASKBOT_URL):
+ #todo: a hack, for real we need to remove this middleware
+ #and switch to the new-style session messages
+ return response
if hasattr(request, 'user') and \
request.user.is_authenticated() and \
'askbot_visitor' not in request.COOKIES :
diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py
index 253e8d97..d50873d9 100644
--- a/askbot/startup_procedures.py
+++ b/askbot/startup_procedures.py
@@ -438,6 +438,22 @@ def test_csrf_cookie_domain():
'setting'
)
+def test_settings_for_test_runner():
+ """makes sure that debug toolbar is disabled when running tests"""
+ errors = list()
+ if 'debug_toolbar' in django_settings.INSTALLED_APPS:
+ errors.append(
+ 'When testing - remove debug_toolbar from INSTALLED_APPS'
+ )
+ if 'debug_toolbar.middleware.DebugToolbarMiddleware' in \
+ django_settings.MIDDLEWARE_CLASSES:
+ errors.append(
+ 'When testing - remove debug_toolbar.middleware.DebugToolbarMiddleware '
+ 'from MIDDLEWARE_CLASSES'
+ )
+ print_errors(errors)
+
+
def run_startup_tests():
"""function that runs
all startup tests, mainly checking settings config so far
@@ -482,6 +498,8 @@ def run_startup_tests():
})
settings_tester.run()
test_media_url()
+ if 'manage.py test' in ' '.join(sys.argv):
+ test_settings_for_test_runner()
@transaction.commit_manually
def run():
diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py
index 8abde42f..f9385bec 100644
--- a/askbot/tests/page_load_tests.py
+++ b/askbot/tests/page_load_tests.py
@@ -483,11 +483,12 @@ class PageLoadTestCase(AskbotTestCase):
class AvatarTests(AskbotTestCase):
def test_avatar_for_two_word_user_works(self):
- self.user = self.create_user('john doe')
- response = self.client.get(
- 'avatar_render_primary',
- kwargs = {'user': 'john doe', 'size': 48}
- )
+ if 'avatar' in settings.INSTALLED_APPS:
+ self.user = self.create_user('john doe')
+ response = self.client.get(
+ 'avatar_render_primary',
+ kwargs = {'user': 'john doe', 'size': 48}
+ )
class QuestionPageRedirectTests(AskbotTestCase):
diff --git a/askbot/user_messages/context_processors.py b/askbot/user_messages/context_processors.py
index f4c5e3ac..230e967c 100644
--- a/askbot/user_messages/context_processors.py
+++ b/askbot/user_messages/context_processors.py
@@ -4,6 +4,7 @@ Context processor for lightweight session messages.
Time-stamp: <2008-07-19 23:16:19 carljm context_processors.py>
"""
+from django.conf import settings as django_settings
from django.utils.encoding import StrAndUnicode
from askbot.user_messages import get_and_delete_messages
@@ -13,6 +14,10 @@ def user_messages (request):
Returns session messages for the current session.
"""
+ if not request.path.startswith('/' + django_settings.ASKBOT_URL):
+ #todo: a hack, for real we need to remove this middleware
+ #and switch to the new-style session messages
+ return {}
messages = request.user.get_and_delete_messages()
#if request.user.is_authenticated():
#else: