from django.db import models
from colorful.fields import RGBColorField
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
null_args = dict(null=True, blank=True)
class Creation(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL)
created = models.DateTimeField(_('created time'), auto_now_add=True)
updated = models.DateTimeField(_('Updated time'), null=True)
class Meta:
abstract = True
class Topic(Creation):
title = models.CharField(max_length=300, unique=True)
body = models.TextField()
tags = models.ManyToManyField('Tag', related_name='topics', blank=True)
class Comment(Creation):
topic = models.ForeignKey(Topic)
body = models.TextField()
class Tag(Creation):
name = models.CharField(_('name'), max_length=64)
color = RGBColorField(**null_args)