87dafa5e8959

Add the comment export script.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Jan 2010 01:01:28 -0500
parents b3eb9a757704
children da98105753a1
branches/tags (none)
files blog/models.py convert-comments.py projects/models.py settings.py

Changes

--- a/blog/models.py	Fri Dec 11 22:22:27 2009 -0500
+++ b/blog/models.py	Sat Jan 09 01:01:28 2010 -0500
@@ -14,10 +14,8 @@
         verbose_name = 'entry'
         verbose_name_plural = 'entries'
     
-    @models.permalink
     def get_absolute_url(self):
-        return ('blog-entry', (self.pub_date.year, self.pub_date.month, 
-                               self.pub_date.day, self.slug),)
+        return u'/blog/%d/%d/%s/' % (self.pub_date.year, self.pub_date.month, self.slug)
     
     def __unicode__(self):
         return u'%s' % (self.title,)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/convert-comments.py	Sat Jan 09 01:01:28 2010 -0500
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+from django.core.management import setup_environ
+import settings
+setup_environ(settings)
+
+from django.contrib.comments.models import Comment
+from django.contrib.sites.models import Site
+from stevelosh.blog.models import Comment as BlogComment
+from stevelosh.projects.models import Comment as ProjectComment
+
+
+site = Site.objects.all()[0]
+blog_comments = BlogComment.objects.filter(spam=False)
+project_comments = ProjectComment.objects.filter(spam=False)
+
+for bc in blog_comments:
+    c = Comment()
+    c.content_object = bc.entry
+    c.user_name = bc.name
+    c.comment = bc.body
+    c.submit_date = bc.submitted
+    c.site = site
+    c.is_public = True
+    c.is_removed = False
+    c.save()
+    print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
+
+for pc in project_comments:
+    c = Comment()
+    c.content_object = pc.project
+    c.user_name = pc.name
+    c.comment = pc.body
+    c.submit_date = pc.submitted
+    c.site = site
+    c.is_public = True
+    c.is_removed = False
+    c.save()
+    print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
--- a/projects/models.py	Fri Dec 11 22:22:27 2009 -0500
+++ b/projects/models.py	Sat Jan 09 01:01:28 2010 -0500
@@ -12,9 +12,8 @@
     posted = models.DateTimeField(blank=False, default=datetime.datetime.now)
     slug = models.SlugField()
     
-    @models.permalink
     def get_absolute_url(self):
-        return ('project-view', (self.slug,),)
+        return u'/projects/%s/' % (self.slug,)
     
     def __unicode__(self):
         return u"%s" % (self.name,)
--- a/settings.py	Fri Dec 11 22:22:27 2009 -0500
+++ b/settings.py	Sat Jan 09 01:01:28 2010 -0500
@@ -94,9 +94,13 @@
     'django.contrib.admin',
     'django.contrib.markup',
     'django.contrib.flatpages',
+    'django.contrib.comments',
     'stevelosh.blog',
     'stevelosh.projects',
     'stevelosh.messengerbag',
     'mobileadmin',
     'typogrify',
+    'disqus',
 )
+
+from deploy import *
\ No newline at end of file