dbf5fe560ec3

Add the snip functions and use them for the admin.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 22 Aug 2009 10:17:28 -0400
parents ae2856e8f8dc
children 8c03bf5d3f9f
branches/tags (none)
files blog/admin.py blog/models.py projects/admin.py projects/models.py

Changes

--- a/blog/admin.py	Fri Aug 21 18:29:07 2009 -0400
+++ b/blog/admin.py	Sat Aug 22 10:17:28 2009 -0400
@@ -18,7 +18,7 @@
 
 class CommentAdmin(admin.ModelAdmin):
     fields = ('name', 'body', 'submitted', 'entry', 'spam')
-    list_display = ('entry', 'name', 'submitted', 'body', 'spam')
+    list_display = ('entry', 'name', 'submitted', 'snip', 'spam')
     search_fields = ('name', 'body')
     list_filter = ('name', 'entry', 'spam')
     date_hierarchy = 'submitted'
--- a/blog/models.py	Fri Aug 21 18:29:07 2009 -0400
+++ b/blog/models.py	Sat Aug 22 10:17:28 2009 -0400
@@ -35,4 +35,7 @@
     
     def __unicode__(self):
         return u'%s on %s' % (self.name, self.entry.title)
-
+    
+    def snip(self):
+        return self.body[:40] + '...' if len(self.body) > 40 else ''
+    
--- a/projects/admin.py	Fri Aug 21 18:29:07 2009 -0400
+++ b/projects/admin.py	Sat Aug 22 10:17:28 2009 -0400
@@ -11,7 +11,7 @@
 
 class CommentAdmin(admin.ModelAdmin):
     fields = ('name', 'body', 'submitted', 'project', 'spam')
-    list_display = ('project', 'name', 'submitted', 'body', 'spam')
+    list_display = ('project', 'name', 'submitted', 'snip', 'spam')
     search_fields = ('name', 'body')
     list_filter = ('name', 'project', 'spam')
     date_hierarchy = 'submitted'
--- a/projects/models.py	Fri Aug 21 18:29:07 2009 -0400
+++ b/projects/models.py	Sat Aug 22 10:17:28 2009 -0400
@@ -33,3 +33,7 @@
     def __unicode__(self):
         return u'%s on %s' % (self.name, self.project.name)
     
+    def snip(self):
+        return self.body[:40] + '...' if len(self.body) > 40 else ''
+    
+