Commits

Adam Knight committed 3fc74ff

Updated code for the new comments.

Comments (0)

Files changed (3)

drupal_support/management/commands/convertdrupal.py

 from sitepoet.models import *
 from sitepoet.templatetags.slugify import slugify
 
-from threadedcomments.models import ThreadedComment
+from sitepoet.comments.models import MPTTComment
 
 def vancode2int(vancode):
     if len(vancode):
                     c_obj = None
                     if len(parents):
                         ct = ContentType.objects.get_for_model(obj.__class__)
-                        obj_comments = ThreadedComment.objects.filter(content_type=ct, object_pk=str(obj.id)).order_by('submit_date')
+                        obj_comments = MPTTComment.objects.filter(content_type=ct, object_pk=str(obj.id)).order_by('submit_date')
                         if debug:
                             print "* Object comments (%d):" % obj_comments.count(), obj_comments
                             print "* Parents (%d):" % len(parents), parents
                         if debug and c_obj: print "** Suspected parent:", c_obj.title
                     
                     # Actually create the comment now
-                    c = ThreadedComment(
+                    c = MPTTComment(
                         content_object = obj,
                         title = unicode(comment.subject)[:200],
                         ip_address = unicode(comment.hostname)[:15],

drupal_support/routers.py

+from models import *
+
+class DrupalRouter(object):
+    """
+    A router to use the "drupal" database for Drupal objects, if it exists.
+    """
+    def db_for_read(self, model, **hints):
+        if model._meta.app_label == 'drupal_support':
+            return 'drupal'
+        return None
+    
+    def db_for_write(self, model, **hints):
+        if model._meta.app_label == 'drupal_support':
+            return 'drupal'
+        return None
+    
+    def allow_relation(self, obj1, obj2, **hints):
+        """
+        If either model is in this app but both are not, reject.
+        """
+        if obj1._meta.app_label == 'drupal_support' or \
+            obj2._meta.app_label == 'drupal_support':
+            if obj1._meta.app_label == obj2._meta.app_label:
+                return True
+            else:
+                return False
+        return None
+    
+    def allow_syncdb(self, db, model):
+        if db == 'drupal'or model._meta.app_label == 'drupal_support':
+            return False
+        return None
-Django==1.2.5
+Django<1.5
 django-tagging==0.3.1
-wsgiref==0.1.2
+django-mptt==0.5.4