Adam Knight committed 714412c

Clean up imports. Fix next/prev links.

Comments (0)

Files changed (4)


 from django.contrib.sites.models import Site
+from milton.models import Section
 def general(request):
     return {
         "site": Site.objects.get_current(),
+        "sections": Section.objects.all(),


 from import BaseCommand, CommandError
 from milton.drupal_support.models import *
-from milton.models import Section, Page, Story, Redirect
+from milton.models import Section, Page, Story, Redirect, ContentHistory
 from milton.templatetags.slugify import slugify
 from milton.threadedcomments.models import MPTTComment
-#!/usr/bin/env python2.5
 ### IMPORTS ###
     textile = None
 import datetime
-import string
 from django.core.urlresolvers import reverse
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.models import ContentType
 from django.db import models
 from django.utils.safestring import mark_safe
-import tagging
 from tagging.fields import TagField
 from milton.managers import *
-from milton.templatetags.slugify import slugify
 ### CONSTANTS ###
-def format_text(format, text):
+def format_text(text_format, text):
     output = text
-    if format == CONTENT_FORMAT_TEXTILE:
+    if text_format == CONTENT_FORMAT_TEXTILE:
         if textile != None:
             output = textile.textile(text)
             print "No Textile support found."
-    elif format == CONTENT_FORMAT_MARKDOWN:
+    elif text_format == CONTENT_FORMAT_MARKDOWN:
         if markdown != None:
             output = markdown.markdown(text)
     def previous(self):
-        try:
-            return self.get_previous_by_date_published()
-        except self.DoesNotExist:
+        query = Story.published.order_by('-date_published', 'id').filter(date_published__lt=self.date_published)[0:1]
+        if len(query):
+            return query[0]
+        else:
             return None
     def next(self):
-        try:
-            return self.get_next_by_date_published()
-        except self.DoesNotExist:
+        query = Story.published.order_by('date_published', 'id').filter(date_published__gt=self.date_published)[0:1]
+        if len(query):
+            return query[0]
+        else:
             return None
     def save(self, *args, **kwargs):
         "options": {
             "teasers": teasers
-        "page": stories_page
+        "page": stories_page,
     if year and month and day: