From 90140cbc1e1e5ce4c79cf872b6cef754b342f0bf Mon Sep 17 00:00:00 2001 From: hrcerqueira Date: Thu, 4 Mar 2010 02:14:18 +0000 Subject: couple of fixes --- .idea/workspace.xml | 373 +++++++++------------------ INSTALL | 46 ++-- forum/models/__init__.py | 2 +- forum/settings.py | 51 ++++ forum/skins/default/templates/header.html | 2 +- forum/skins/default/templates/index.html | 4 +- forum/skins/default/templates/questions.html | 118 +++------ forum/skins/default/templates/users.html | 4 +- forum/urls.py | 2 +- settings.py | 8 +- 10 files changed, 240 insertions(+), 370 deletions(-) create mode 100755 forum/settings.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c8f27edf..81da1ab9 100755 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -22,22 +22,23 @@ - - + + - + - + - + + @@ -47,21 +48,22 @@ - + - + + - + @@ -75,9 +77,9 @@ - - + + @@ -86,6 +88,7 @@ + @@ -103,20 +106,20 @@ - - + + - + - + @@ -130,41 +133,40 @@ - - + - + - - + - + + - - + + @@ -177,8 +179,8 @@ - + @@ -186,14 +188,14 @@ - - + + - + @@ -204,57 +206,56 @@ - + - + - + - + - - - + + - + - + - - + + - + @@ -264,11 +265,11 @@ - + - + @@ -277,8 +278,8 @@ - + @@ -289,8 +290,8 @@ - + @@ -309,8 +310,8 @@ - + @@ -375,91 +376,91 @@ - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + @@ -475,22 +476,22 @@ @@ -549,114 +550,6 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/INSTALL b/INSTALL index f70b3ec7..bd3ac60d 100644 --- a/INSTALL +++ b/INSTALL @@ -56,7 +56,7 @@ Notice that you will need to register with recaptcha.net and receive recaptcha public and private keys that need to be saved in your settings_local.py file -NOTES: django_authopenid is included into OSQA code +NOTES: django_authopenid is included into OSQA code and is significantly modified. http://code.google.com/p/django-authopenid/ no need to install this library @@ -66,7 +66,7 @@ B. INSTALLATION make osqa installation server-readable on Linux command might be: chown -R yourlogin:apache /path/to/OSQA - + directories templates/upfiles and log must be server writable on Linux type chmod @@ -77,28 +77,28 @@ B. INSTALLATION 1. Settings file -Copy settings_local.py.dist to settings_local.py and -update all your settings. Check settings.py and update +Copy settings_local.py.dist to settings_local.py and +update all your settings. Check settings.py and update it as well if necessory. Section C explains configuration paramaters. 2. Database -Prepare your database by using the same database/account +Prepare your database by using the same database/account configuration from above. e.g, create database osqa DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci; grant all on osqa.* to 'osqa'@'localhost'; And then run "python manage.py syncdb" to synchronize your database. -3. Running OSQA on the development server +3. Running OSQA on the development server -Run "python manage.py runserver" to startup django +Run "python manage.py runserver" to startup django development environment. (Under Linux you can use command "python manage.py runserver `hostname -i`:8000", where you can use any other available number for the port) -you might want to have DEBUG=True in the beginning of settings.py +you might want to have DEBUG=True in the beginning of settings.py when using the test server 4. Installation under Apache/WSGI @@ -118,7 +118,7 @@ import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() ----------- -insert method is used for path because if the forum directory name +insert method is used for path because if the forum directory name is by accident the same as some other python module you wull see strange errors - forum won't be found even though it's in the python path. for example using name "test" is @@ -133,7 +133,7 @@ WSGISocketPrefix /path/to/socket/sock #must be readable and writable by apache WSGIPythonHome /usr/local #must be readable by apache WSGIPythonEggs /var/python/eggs #must be readable and writable by apache -#NOTE: all urs below will need to be adjusted if +#NOTE: all urs below will need to be adjusted if #settings.FORUM_SCRIPT_ALIAS !='' (e.g. = 'forum/') #this allows "rooting" forum at http://example.com/forum, if you like @@ -144,8 +144,8 @@ WSGIPythonEggs /var/python/eggs #must be readable and writable by apache #run mod_wsgi process for django in daemon mode #this allows avoiding confused timezone settings when #another application runs in the same virtual host - WSGIDaemonProcess OSQA - WSGIProcessGroup OSQA + WSGIDaemonProcess OSQA + WSGIProcessGroup OSQA #force all content to be served as static files #otherwise django will be crunching images through itself wasting time @@ -213,42 +213,42 @@ WSGIPythonEggs /var/python/eggs #must be readable and writable by apache in settings_local.py set USE_SPHINX_SEARCH=True - adjust other settings that have SPHINX_* prefix accordingly + adjust other settings that have SPHINX_* prefix accordingly remember that there must be trailing comma in parentheses for SHPINX_SEARCH_INDICES tuple - particlarly with just one item! - + in settings.py look for INSTALLED_APPS and uncomment #'djangosphinx', - + 6. Email subscriptions - + This function at the moment requires Django 1.1 edit paths in the file cron/send_email_alerts set up a cron job to call cron/send_email_alerts once or twice a day - subscription sender may be tested manually in shell + subscription sender may be tested manually in shell by calling cron/send_email_alerts 7. Sitemap Sitemap will be available at /sitemap.xml e.g yoursite.com/forum/sitemap.xml -google will be pinged each time question, answer or +google will be pinged each time question, answer or comment is saved or a question deleted -for this to be useful - do register you sitemap with Google at +for this to be useful - do register you sitemap with Google at https://www.google.com/webmasters/tools/ 8. Miscellaneous -There are some demo scripts under sql_scripts folder, -including badges and test accounts for CNProg.com. You +There are some demo scripts under sql_scripts folder, +including badges and test accounts for CNProg.com. You don't need them to run your sample. C. CONFIGURATION PARAMETERS -#the only parameter that needs to be touched in settings.py is +#the only parameter that needs to be touched in settings.py is DEBUG=False #set to True to enable debug mode #all forum parameters are set in file settings_local.py @@ -269,7 +269,7 @@ EMAIL_USE_TLS=False TIME_ZONE = 'America/Tijuana' APP_TITLE = u'OSQA Q&A Forum' #title of your forum APP_KEYWORDS = u'OSQA,forum,community' #keywords for search engines -APP_DESCRIPTION = u'Ask and answer questions.' #site description for searche engines +APP_DESCRIPTION = u'Ask and answer questions.' #site description for searche engines APP_INTRO = u'

Ask and answer questions, make the world better!

' #slogan that goes to front page in logged out mode APP_COPYRIGHT = '' #copyright message diff --git a/forum/models/__init__.py b/forum/models/__init__.py index fee52447..4e29c215 100755 --- a/forum/models/__init__.py +++ b/forum/models/__init__.py @@ -93,7 +93,7 @@ def delete_messages(self): def get_profile_url(self): """Returns the URL for this User's profile.""" - return '%s%s/' % (reverse('user', args=[self.id]), slugify(self.username)) + return reverse('user_prof', kwargs={'id': self.id, 'slug': slugify(self.username)}) def get_profile_link(self): profile_link = u'%s' % (self.get_profile_url(),self.username) diff --git a/forum/settings.py b/forum/settings.py new file mode 100755 index 00000000..f3a665b2 --- /dev/null +++ b/forum/settings.py @@ -0,0 +1,51 @@ +import os + + +INSTALLED_APPS = ['forum'] + +MIDDLEWARE_CLASSES = [ + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware', + 'forum.middleware.pagesize.QuestionsPageSizeMiddleware', + 'forum.middleware.cancel.CancelActionMiddleware', + 'django.middleware.transaction.TransactionMiddleware', +] + +TEMPLATE_LOADERS = [ + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', + 'forum.modules.module_templates_loader', + 'forum.skins.load_template_source', +] + +TEMPLATE_CONTEXT_PROCESSORS = [ + 'django.core.context_processors.request', + 'forum.context.application_settings', + 'forum.user_messages.context_processors.user_messages', + 'django.core.context_processors.auth', +] + +TEMPLATE_DIRS = [ + os.path.join(os.path.dirname(__file__),'skins').replace('\\','/'), +] + +def setup_settings(settings): + + if (hasattr(settings, 'DEBUG') and getattr(settings, 'DEBUG')): + try: + import debug_toolbar + INSTALLED_APPS.append('debug_toolbar') + MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware') + except: + pass + + + settings.INSTALLED_APPS = set(settings.INSTALLED_APPS) | set(INSTALLED_APPS) + settings.MIDDLEWARE_CLASSES = set(settings.MIDDLEWARE_CLASSES) | set(MIDDLEWARE_CLASSES) + settings.TEMPLATE_LOADERS = set(settings.TEMPLATE_LOADERS) | set(TEMPLATE_LOADERS) + settings.TEMPLATE_CONTEXT_PROCESSORS = set(settings.TEMPLATE_CONTEXT_PROCESSORS) | set(TEMPLATE_CONTEXT_PROCESSORS) + settings.TEMPLATE_DIRS = set(settings.TEMPLATE_DIRS) | set(TEMPLATE_DIRS) + + \ No newline at end of file diff --git a/forum/skins/default/templates/header.html b/forum/skins/default/templates/header.html index cb12bb97..e65ac73a 100755 --- a/forum/skins/default/templates/header.html +++ b/forum/skins/default/templates/header.html @@ -5,7 +5,7 @@