# HG changeset patch # User Steve Losh # Date 1250950648 14400 # Node ID dbf5fe560ec342bb25eb8248a68317354e169916 # Parent ae2856e8f8dc4d00a4265986e84b83f8cd188147 Add the snip functions and use them for the admin. diff -r ae2856e8f8dc -r dbf5fe560ec3 blog/admin.py --- 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' diff -r ae2856e8f8dc -r dbf5fe560ec3 blog/models.py --- 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 '' + diff -r ae2856e8f8dc -r dbf5fe560ec3 projects/admin.py --- 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' diff -r ae2856e8f8dc -r dbf5fe560ec3 projects/models.py --- 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 '' + +