Start implementing reply context! It's ugly and doesn't actually link the original post yet but you *can* see the original post's author and content :3

This commit is contained in:
Danielle McLean 2017-11-16 21:52:42 +11:00
parent fb9e9a24c9
commit e72a6b01f0
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
7 changed files with 78 additions and 13 deletions

View file

@ -3,6 +3,7 @@ from django.contrib.sites.models import Site
from django.db import models
from django.urls import reverse
from itertools import groupby
from mf2util import interpret
from slugify import slugify
from textwrap import shorten
from urllib.parse import urljoin
@ -12,6 +13,7 @@ from model_utils.models import TimeStampedModel
from users.models import Profile
from . import kinds
from lemoncurry import requests
ENTRY_KINDS = [(k.id, k.id) for k in kinds.all]
@ -34,10 +36,9 @@ class Entry(ModelMeta, TimeStampedModel):
photo = models.ImageField(blank=True)
content = models.TextField()
# The URL of an entry (anywhere on the web) that should become an embedded
# h-cite. Can become a u-like-of, u-repost-of, or u-in-reply-to depending
# on the post type.
cite = models.CharField(max_length=255, blank=True)
in_reply_to = models.CharField(max_length=255, blank=True)
like_of = models.CharField(max_length=255, blank=True)
repost_of = models.CharField(max_length=255, blank=True)
author = models.ForeignKey(
get_user_model(),
@ -45,6 +46,15 @@ class Entry(ModelMeta, TimeStampedModel):
on_delete=models.CASCADE,
)
@property
def reply_context(self):
if not self.in_reply_to:
return None
return interpret(
requests.mf2(self.in_reply_to).to_dict(),
self.in_reply_to
)
@property
def published(self):
return self.created