From 28e4a71cae9f1aa21f4af0c8574e9a7492c0b270 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 13 Nov 2017 08:42:31 +1100 Subject: [PATCH] Begin implementing support for replies, likes, and reposts - there's a DB field for storing the original post's URL, but it's not actually used yet --- entries/kinds.py | 20 ++++++++++++++- entries/migrations/0007_auto_20171113_0841.py | 25 +++++++++++++++++++ entries/models.py | 5 ++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 entries/migrations/0007_auto_20171113_0841.py diff --git a/entries/kinds.py b/entries/kinds.py index 09b0ce1..447454c 100644 --- a/entries/kinds.py +++ b/entries/kinds.py @@ -42,6 +42,24 @@ Photo = Entry( plural='photos', ) -all = (Note, Article, Photo) +Reply = Entry( + id='reply', + icon='fa fa-comment', + plural='replies', +) + +Like = Entry( + id='like', + icon='fa fa-heart', + plural='likes', +) + +Repost = Entry( + id='repost', + icon='fa fa-retweet', + plural='reposts', +) + +all = (Note, Article, Photo, Reply, Like, Repost) from_id = {k.id: k for k in all} from_plural = {k.plural: k for k in all} diff --git a/entries/migrations/0007_auto_20171113_0841.py b/entries/migrations/0007_auto_20171113_0841.py new file mode 100644 index 0000000..40fc4f4 --- /dev/null +++ b/entries/migrations/0007_auto_20171113_0841.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.7 on 2017-11-12 21:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('entries', '0006_auto_20171102_1200'), + ] + + operations = [ + migrations.AddField( + model_name='entry', + name='cite', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name='entry', + name='kind', + field=models.CharField(choices=[('note', 'note'), ('article', 'article'), ('photo', 'photo'), ('reply', 'reply'), ('like', 'like'), ('repost', 'repost')], db_index=True, default='note', max_length=30), + ), + ] diff --git a/entries/models.py b/entries/models.py index 7c4644a..2220aa2 100644 --- a/entries/models.py +++ b/entries/models.py @@ -34,6 +34,11 @@ 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) + author = models.ForeignKey( get_user_model(), related_name='entries',