all repos — comments @ bd3b6617067c3d06405b32e99ca1483ed7898254

django app for embedding comment threads in a static site via iframes

models.py (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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