oacpl/forum/models.py

34 lines
797 B
Python
Raw Normal View History

2017-08-26 11:40:35 -04:00
from django.db import models
from django.contrib.auth.models import User
2018-01-06 12:11:27 -05:00
from tinymce.models import HTMLField
2017-08-26 11:40:35 -04:00
class Thread(models.Model):
2018-01-14 19:32:00 -05:00
name = models.CharField(max_length=255)
2017-08-26 11:40:35 -04:00
def __str__(self):
2018-01-14 19:32:00 -05:00
return self.name
2017-08-26 11:40:35 -04:00
class Post(models.Model):
creator = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
2018-01-06 12:11:27 -05:00
resolved = models.BooleanField(default=False)
2018-01-14 19:32:00 -05:00
thread = models.ForeignKey(Thread)
2018-01-06 12:11:27 -05:00
title = models.CharField(max_length=255)
question = HTMLField()
2017-08-26 11:40:35 -04:00
def __str__(self):
return self.title
class Comment(models.Model):
post = models.ForeignKey(Post)
2018-01-06 12:11:27 -05:00
reply = HTMLField()
2017-08-26 11:40:35 -04:00
creator = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.reply