2011-06-02 19:39:14 -07:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.db import models
|
|
|
|
|
2011-06-05 09:51:56 -07:00
|
|
|
from taggit.managers import TaggableManager
|
|
|
|
|
2011-06-02 19:39:14 -07:00
|
|
|
class Snipt(models.Model):
|
|
|
|
"""An individual code snippet."""
|
|
|
|
|
2011-06-05 09:51:56 -07:00
|
|
|
user = models.ForeignKey(User)
|
2011-06-02 19:39:14 -07:00
|
|
|
|
|
|
|
title = models.CharField(max_length=255)
|
|
|
|
slug = models.SlugField()
|
2011-06-05 09:51:56 -07:00
|
|
|
tags = TaggableManager()
|
2011-06-02 19:39:14 -07:00
|
|
|
|
|
|
|
lexer = models.CharField(max_length=50)
|
|
|
|
code = models.TextField()
|
|
|
|
stylized = models.TextField()
|
|
|
|
|
|
|
|
key = models.CharField(max_length=100)
|
|
|
|
public = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
# TODO Set auto_now_add back to True for production!
|
|
|
|
created = models.DateTimeField(auto_now_add=False, editable=False)
|
|
|
|
modified = models.DateTimeField(auto_now=True, editable=False)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return u'%s' %(self.title)
|
2011-06-05 08:55:27 -07:00
|
|
|
|
|
|
|
class Comment(models.Model):
|
|
|
|
"""A comment on a Snipt"""
|
|
|
|
|
2011-06-05 09:51:56 -07:00
|
|
|
user = models.ForeignKey(User)
|
|
|
|
snipt = models.ForeignKey(Snipt)
|
2011-06-05 08:55:27 -07:00
|
|
|
|
|
|
|
comment = models.TextField()
|
|
|
|
|
|
|
|
# TODO Set auto_now_add back to True for production!
|
|
|
|
created = models.DateTimeField(auto_now_add=False, editable=False)
|
|
|
|
modified = models.DateTimeField(auto_now=True, editable=False)
|