Created
September 20, 2011 10:45
-
-
Save acgray/1228843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.contrib.sites.models import Site | |
from django.db import models | |
from filebrowser.fields import FileBrowseField | |
from mptt.forms import TreeNodeChoiceField, TreeNodeMultipleChoiceField | |
from mptt.models import MPTTModel, TreeForeignKey | |
from taggit.managers import TaggableManager | |
from ckeditor.fields import RichTextField | |
class Section(MPTTModel): | |
name = models.CharField(max_length=255) | |
parent = TreeForeignKey('self', null=True, blank=True, related_name='children') | |
def __unicode__(self): | |
return self.name | |
class Article(models.Model): | |
title = models.CharField(max_length=255) | |
slug = models.SlugField() | |
summary = models.TextField(blank=True) | |
bullets = models.TextField(blank=True) | |
body = RichTextField() | |
# Multimedia | |
main_image = FileBrowseField(max_length=255,blank=True) | |
main_image_credit = models.CharField(max_length=255,blank=True) | |
# Publishing info | |
pub_date = models.DateTimeField() | |
pub_status = models.CharField( | |
(u'Publication status'),max_length=1, | |
choices=( | |
('D','Draft'), | |
('E','Edit'), | |
('P','Published'), | |
('T','Trash') | |
), | |
help_text=u'Only published items will appear on the site.', | |
default='D') | |
sites = models.ManyToManyField(Site) | |
# Author information | |
authors = models.ManyToManyField(User) | |
authors_extra = models.CharField(max_length=255,blank=True) | |
# Taxonomy | |
tags = TaggableManager(blank=True) | |
section = TreeForeignKey(Section) | |
def __unicode__(self): | |
return self.title | |
class Meta: | |
permissions = ( | |
("can_change_pub_status", 'Can change published status'), | |
) | |
class Review(Article): | |
# Review-specific stuff | |
rating = models.CharField(max_length=1, choices=( | |
(1,'1'), | |
(2,'2'), | |
(3,'3'), | |
(4,'4'), | |
(5,'5') | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment