comments/models.py

23 lines
926 B
Python
Raw Permalink Normal View History

2020-04-28 23:01:19 +00:00
# comments/models.py
2021-08-26 00:53:43 +00:00
# (c) 2020 Derek Stevens <nilix@nilfm.cc>
2020-04-28 23:01:19 +00:00
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)
2020-06-27 05:13:10 +00:00
comment_data = models.TextField(max_length=4096, blank=False)
2020-04-28 23:01:19 +00:00
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