oacpl/forum/models.py

34 lines
913 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):
2018-05-24 16:11:59 -04:00
creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
2017-08-26 11:40:35 -04:00
created = models.DateTimeField(auto_now_add=True)
2018-01-06 12:11:27 -05:00
resolved = models.BooleanField(default=False)
2018-05-24 16:11:59 -04:00
thread = models.ForeignKey(Thread, on_delete=models.DO_NOTHING)
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):
2018-05-24 16:11:59 -04:00
post = models.ForeignKey(Post, on_delete=models.DO_NOTHING)
2018-01-06 12:11:27 -05:00
reply = HTMLField()
2018-05-24 16:11:59 -04:00
creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
2017-08-26 11:40:35 -04:00
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.reply