aboutsummaryrefslogtreecommitdiff
path: root/apps/forum/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/forum/models.py')
-rw-r--r--apps/forum/models.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/apps/forum/models.py b/apps/forum/models.py
index d0f6b6f..3a54514 100644
--- a/apps/forum/models.py
+++ b/apps/forum/models.py
@@ -28,8 +28,10 @@ class CategoryManager(models.Manager):
class Category(models.Model):
- title = models.CharField(max_length=120)
+ name = models.CharField(max_length=120)
slug = models.SlugField()
+ description = models.CharField(max_length=350)
+ color_rgb = models.CharField(max_length=20, blank=True)
date_created = models.DateTimeField(auto_now=False, auto_now_add=True)
date_updated = models.DateTimeField(auto_now=True, auto_now_add=False)
@@ -44,8 +46,11 @@ class Category(models.Model):
objects = CategoryManager()
- def __unicode__(self):
- return self.title
+ def __str__(self):
+ return self.name
+
+ def get_absolute_url(self):
+ return reverse("forum:category-detail", kwargs={'slug': self.slug})
class TopicManager(models.Manager):
@@ -62,10 +67,9 @@ class TopicManager(models.Manager):
class Topic(models.Model):
-
category = models.ForeignKey(Category, on_delete=models.CASCADE)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='topic_user')
- last_post_userj= models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='topic_last_post_user', blank=True, null=True)
+ last_post_user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='topic_last_post_user', blank=True, null=True)
highest_post = models.ForeignKey('Post', on_delete=models.CASCADE, related_name='topic_highest_post', blank=True, null=True)
title = models.CharField(max_length=255)
@@ -119,9 +123,9 @@ class Post(models.Model):
('reply', 'reply'),
)
post_type = models.CharField(max_length=60, choices=POST_TYPE_CHOICES)
- post_body_text = models.TextField(blank=True, null=False)
- post_body_html = models.TextField(blank=True, null=True)
- post_body_json = models.TextField(blank=True, null=True)
+ body_text = models.TextField(blank=True, null=False)
+ body_html = models.TextField(blank=True, null=True)
+ body_json = models.TextField(blank=True, null=True)
date_created = models.DateTimeField(auto_now=False, auto_now_add=True, blank=True)
date_updated = models.DateTimeField(auto_now=True, auto_now_add=False, blank=True)
@@ -142,4 +146,4 @@ class Post(models.Model):
verbose_name_plural = "Posts"
def __str__(self):
- return '%s - %s' % (self.raw, self.topic.title)
+ return '%s - %s' % (self.topic.title, self.id)