From 3c9079c6255dbc83bd205e5f0147d330ee0f97e0 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Wed, 20 Jun 2012 16:55:05 -0600 Subject: added setup_procedures for haystack and setup_templates --- askbot/setup_templates/settings.py | 8 ++++++++ askbot/setup_templates/settings.py.mustache | 9 +++++++++ askbot/startup_procedures.py | 20 +++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 32af9920..d0a34d55 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -161,6 +161,7 @@ INSTALLED_APPS = ( 'django.contrib.humanize', 'django.contrib.sitemaps', #'debug_toolbar', + #'haystack', 'askbot', 'askbot.deps.django_authopenid', #'askbot.importers.stackexchange', #se loader @@ -229,3 +230,10 @@ CSRF_COOKIE_NAME = 'askbot_csrf' STATICFILES_DIRS = ( os.path.join(ASKBOT_ROOT, 'skins'),) RECAPTCHA_USE_SSL = True + +#HAYSTACK_SETTINGS +ENABLE_HAYSTACK_SEARCH = False +HAYSTACK_SITECONF = 'askbot.search.haystack' +#more information +#http://django-haystack.readthedocs.org/en/v1.2.7/settings.html +HAYSTACK_SEARCH_ENGINE = 'simple' diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index eb1cb1c1..07e6aef0 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -160,6 +160,8 @@ INSTALLED_APPS = ( 'django.contrib.humanize', 'django.contrib.sitemaps', #'debug_toolbar', + #Optional, to enable haystack search + #'haystack', 'askbot', 'askbot.deps.django_authopenid', #'askbot.importers.stackexchange', #se loader @@ -230,3 +232,10 @@ STATIC_ROOT = os.path.join(PROJECT_ROOT, "static") STATICFILES_DIRS = (os.path.join(ASKBOT_ROOT, 'skins'),) RECAPTCHA_USE_SSL = True + +#HAYSTACK_SETTINGS +ENABLE_HAYSTACK_SEARCH = False +HAYSTACK_SITECONF = 'askbot.search.haystack' +#more information +#http://django-haystack.readthedocs.org/en/v1.2.7/settings.html +HAYSTACK_SEARCH_ENGINE = 'simple' diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index 0fec6d5f..544a94fb 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -482,13 +482,23 @@ def test_avatar(): short_message = True ) +def test_haystack(): + if 'haystack' in django_settings.INSTALLED_APPS: + try_import('haystack', 'django-haystack', short_message = True) + if not hasattr(django_settings, 'HAYSTACK_SEARCH_ENGINE'): + message = 'Please add HAYSTACK_SEARCH_ENGINE = simple, for more info please checkout: http://django-haystack.readthedocs.org/en/v1.2.7/settings.html#haystack-search-engine' + raise AskbotConfigError(message) + if not hasattr(django_settings, 'HAYSTACK_SITECONF'): + message = 'Please add HAYSTACK_SITECONF = "askbot.search.haystack"' + raise AskbotConfigError(message) + def test_custom_user_profile_tab(): setting_name = 'ASKBOT_CUSTOM_USER_PROFILE_TAB' tab_settings = getattr(django_settings, setting_name, None) if tab_settings: if not isinstance(tab_settings, dict): print "Setting %s must be a dictionary!!!" % setting_name - + name = tab_settings.get('NAME', None) slug = tab_settings.get('SLUG', None) func_name = tab_settings.get('CONTENT_GENERATOR', None) @@ -528,6 +538,7 @@ def run_startup_tests(): #test_csrf_cookie_domain() test_staticfiles() test_avatar() + test_haystack() settings_tester = SettingsTester({ 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY': { 'value': True, @@ -557,6 +568,13 @@ def run_startup_tests(): 'RECAPTCHA_USE_SSL': { 'value': True, 'message': 'Please add: RECAPTCHA_USE_SSL = True' + }, + 'ENABLE_HAYSTACK_SEARCH': { + 'message': 'Please add: ENABLE_HAYSTACK_SEARCH = False or True according to your setup' + }, + 'HAYSTACK_SITECONF': { + 'value': 'askbot.search.haystack', + 'message': 'Please add: HAYSTACK_SITECONF = "askbot.search.haystack"' } }) settings_tester.run() -- cgit v1.2.3-1-g7c22