comments/models.py
2020-04-28 19:01:19 -04:00

22 lines
927 B
Python

# comments/models.py
# (c) 2020 Derek Stevens <drkste@zoho.com>
from django.db import models
from datetime import datetime
class Comment(models.Model):
comment_author = models.CharField(max_length=128, blank=False)
comment_author_email = models.CharField(max_length=128, blank=False)
comment_date = models.DateTimeField(default=datetime.now, blank=True)
comment_data = models.CharField(max_length=4096, blank=False)
hidden = models.BooleanField(default=False)
next = models.ForeignKey('self', on_delete=models.SET_NULL, null=True)
def __str__(self):
return self.comment_author + " <" + self.comment_author_email + "> @" + self.comment_date.strftime('%Y-%m-%d %H:%M') + ": " + self.comment_data
class Thread(models.Model):
thread_id = models.CharField(primary_key=True, max_length=64)
root_comment = models.ForeignKey(Comment, on_delete=models.SET_NULL, null=True)
def __str__(self):
return self.thread_id