From a303250bfd22f80c90a3bcc7f5ceb8b06e8bdbb1 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Fri, 23 Dec 2011 10:07:03 -0300 Subject: initial django 1.4 support --- askbot/feed.py | 22 +++++++++++++--------- askbot/setup_templates/settings.py.mustache | 16 ++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/askbot/feed.py b/askbot/feed.py index 7f41fd4f..337db470 100644 --- a/askbot/feed.py +++ b/askbot/feed.py @@ -12,7 +12,11 @@ """ #!/usr/bin/env python #encoding:utf-8 -from django.contrib.syndication.feeds import Feed +try: + from django.contrib.syndication.feeds import Feed +except ImportError: + from django.contrib.syndication.views import Feed + from django.contrib.contenttypes.models import ContentType from django.utils.translation import ugettext as _ from django.core.exceptions import ObjectDoesNotExist @@ -32,7 +36,7 @@ class RssIndividualQuestionFeed(Feed): if len(bits) != 1: raise ObjectDoesNotExist return Question.objects.get(id__exact = bits[0]) - + def item_link(self, item): """get full url to the item """ @@ -58,7 +62,7 @@ class RssIndividualQuestionFeed(Feed): content_type = ContentType.objects.get_for_model(Question) ) ) - + answer_content_type = ContentType.objects.get_for_model(Answer) answers = Answer.objects.filter(question = item.id) for answer in answers: @@ -71,7 +75,7 @@ class RssIndividualQuestionFeed(Feed): ) return itertools.chain(*chain_elements) - + def item_title(self, item): """returns the title for the item """ @@ -83,7 +87,7 @@ class RssIndividualQuestionFeed(Feed): elif item.post_type == "comment": title = "Comment by %s for %s" % (item.user, self.title) return title - + def item_description(self, item): """returns the description for the item """ @@ -128,7 +132,7 @@ class RssLastestQuestionsFeed(Feed): because the slug can change """ return self.link + item.get_absolute_url(no_slug = True) - + def item_description(self, item): """returns the desciption for the item """ @@ -152,12 +156,12 @@ class RssLastestQuestionsFeed(Feed): if tags: #if there are tags in GET, filter the #questions additionally - for tag in tags: + for tag in tags: qs = qs.filter(tags__name = tag) - + return qs.order_by('-last_activity_at')[:30] - + def main(): """main function for use as a script diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 79b98814..7a9f2a19 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -17,12 +17,16 @@ ADMINS = ( MANAGERS = ADMINS -DATABASE_ENGINE = 'postgresql_psycopg2' # only postgres (>8.3) and mysql are supported so far others have not been tested yet -DATABASE_NAME = '{{database_name}}' # Or path to database file if using sqlite3. -DATABASE_USER = '{{database_user}}' # Not used with sqlite3. -DATABASE_PASSWORD = '{{database_password}}' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '{{database_name}}', # Or path to database file if using sqlite3. + 'USER': '{{database_user}}', # Not used with sqlite3. + 'PASSWORD': '{{database_password}}', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} #outgoing mail server settings SERVER_EMAIL = '' -- cgit v1.2.3-1-g7c22