Commits

Adam Knight committed 714412c

Clean up imports. Fix next/prev links.

Comments (0)

Files changed (4)

context_preprocessors/__init__.py

 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(),
     }

drupal_support/management/commands/convertdrupal.py

 from django.core.management.base 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 ###
 
 try:
     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 ###
 
 ### GLOBAL FUNCTIONS ###
 
-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)
         else:
             print "No Textile support found."
-    elif format == CONTENT_FORMAT_MARKDOWN:
+    elif text_format == CONTENT_FORMAT_MARKDOWN:
         if markdown != None:
             output = markdown.markdown(text)
         else:
     
     @property
     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
     
     @property
     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: