My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.db.models import permalink
from django.contrib.auth.models import User
from tagging.fields import TagField
from basic.blog.managers import PublicManager

import tagging


class Category(models.Model):
"""Category model."""
title = models.CharField(_('title'), max_length=100)
slug = models.SlugField(_('slug'), unique=True)

class Meta:
verbose_name = _('category')
verbose_name_plural = _('categories')
db_table = 'blog_categories'
ordering = ('title',)

class Admin:
pass

def __unicode__(self):
return u'%s' % self.title

@permalink
def get_absolute_url(self):
return ('blog_category_detail', None, {'slug': self.slug})


class Post(models.Model):
"""Post model."""
STATUS_CHOICES = (
(1, _('Draft')),
(2, _('Public')),
)
title = models.CharField(_('title'), max_length=200)
slug = models.SlugField(_('slug'), unique_for_date='publish')
author = models.ForeignKey(User, blank=True, null=True)
body = models.TextField(_('body'))
tease = models.TextField(_('tease'), blank=True)
status = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=2)
allow_comments = models.BooleanField(_('allow comments'), default=True)
publish = models.DateTimeField(_('publish'))
created = models.DateTimeField(_('created'), auto_now_add=True)
modified = models.DateTimeField(_('modified'), auto_now=True)
categories = models.ManyToManyField(Category, blank=True)
tags = TagField()
objects = PublicManager()

class Meta:
verbose_name = _('post')
verbose_name_plural = _('posts')
db_table = 'blog_posts'
ordering = ('-publish',)
get_latest_by = 'publish'

class Admin:
list_display = ('title', 'publish', 'status')
list_filter = ('publish', 'categories', 'status')
search_fields = ('title', 'body')

def __unicode__(self):
return u'%s' % self.title

@permalink
def get_absolute_url(self):
return ('blog_detail', None, {
'year': self.publish.year,
'month': self.publish.strftime('%b').lower(),
'day': self.publish.day,
'slug': self.slug
})

def get_previous_post(self):
return self.get_previous_by_publish(status__gte=2)

def get_next_post(self):
return self.get_next_by_publish(status__gte=2)
Show details Hide details

Change log

r63 by nat...@playgroundblues.com on Sep 02, 2008   Diff
Made blog slug field unique for date,
updated PhoneNumberFields to use
localflavor instead of legacy validators
Go to: 
Project members, sign in to write a code review

Older revisions

r54 by nat...@playgroundblues.com on Jul 18, 2008   Diff
Updating all apps to work with
newforms admin branch merge
r51 by nat...@playgroundblues.com on Jul 14, 2008   Diff
Fixed bug that prevented you to create
a Draft post in the admin. Added
get_next_post and get_previous_post
methods to be used in front end
templates. These methods will not
...
r50 by nat...@playgroundblues.com on Jun 17, 2008   Diff
BlogPostFeed is now BlogPostsFeed and
there is a new BlogPostsByCategory.
All revisions of this file

File info

Size: 2664 bytes, 81 lines
Hosted by Google Code