diff options
author | luxagraf <sng@luxagraf.net> | 2019-01-13 11:42:01 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-01-13 11:42:01 -0600 |
commit | 5b9343d77d8321e44d1ffc60769c651771dc38dd (patch) | |
tree | 8bbce1b415fbf2fd4c4ee1a7913ca41d362216ec /apps/forum/models.py | |
parent | 261f9df4911f861a71e11eb3f0bfbe1a5a5d12b9 (diff) |
Refactored Javascript, started on forums
Diffstat (limited to 'apps/forum/models.py')
-rw-r--r-- | apps/forum/models.py | 22 |
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) |