diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/models.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/models.py index 6d830c2..989e012 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/models.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/models.py @@ -1,10 +1,29 @@ from django.db import models -class Attachment(models.Model): - pass +from . import util +class Attachment(models.Model): + filename = models.CharField(max_length=256) + filepath = models.CharField(max_length=256) + width = models.IntegerField() + height = models.IntegerField() + class Post(models.Model): - pass + msgid = models.CharField(max_length=256, primary_key=True) + reference = models.CharField(max_length=256) + message = models.TextField() + subject = models.CharField(max_length=256) + name = models.CharField(max_length=256) + pubkey = models.CharField(max_length=64) + signature = models.CharField(max_length=64) + + def get_absolute_url(self): + from django.urls import reverse + op = self.msgid + if self.reference != self.msgid: + op = self.reference + + return reverse('frontend.views.threadpage', args=[util.hashid(op)]) class Board(models.Model): pass diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py new file mode 100644 index 0000000..53c2d05 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py @@ -0,0 +1,5 @@ +import hashlib + + +def hashid(msgid): + return hashlib.sha1().hexdigest('%s' % msgid).decode('ascii')