From 8b00cf8a1a5657f8d9d6e2b35672da07687ff08a Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 20 Nov 2017 11:19:08 +1100 Subject: [PATCH] Add cat support to the micropub endpoint, so new posts will have appropriate cats --- micropub/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/micropub/views.py b/micropub/views.py index 8b453eb..e3c3e93 100644 --- a/micropub/views.py +++ b/micropub/views.py @@ -7,7 +7,7 @@ from django.views.decorators.csrf import csrf_exempt from urllib.parse import urljoin from entries.jobs import ping_hub, send_mentions -from entries.models import Entry +from entries.models import Cat, Entry from entries.kinds import Article, Note, Reply, Like, Repost from lemoncurry import utils from lemonauth import tokens @@ -45,8 +45,15 @@ class MicropubView(View): entry.repost_of = post['repost-of'] kind = Repost + cats = [ + Cat.objects.from_name(c) for c in + post.getlist('category') + post.getlist('category[]') + ] + entry.kind = kind.id entry.save() + entry.cats = cats + entry.save() base = utils.origin(request) perma = urljoin(base, entry.url)