Add cat support to the micropub endpoint, so new posts will have appropriate cats

This commit is contained in:
Danielle McLean 2017-11-20 11:19:08 +11:00
parent 829bb4a20f
commit 8b00cf8a1a
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -7,7 +7,7 @@ from django.views.decorators.csrf import csrf_exempt
from urllib.parse import urljoin from urllib.parse import urljoin
from entries.jobs import ping_hub, send_mentions 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 entries.kinds import Article, Note, Reply, Like, Repost
from lemoncurry import utils from lemoncurry import utils
from lemonauth import tokens from lemonauth import tokens
@ -45,8 +45,15 @@ class MicropubView(View):
entry.repost_of = post['repost-of'] entry.repost_of = post['repost-of']
kind = Repost kind = Repost
cats = [
Cat.objects.from_name(c) for c in
post.getlist('category') + post.getlist('category[]')
]
entry.kind = kind.id entry.kind = kind.id
entry.save() entry.save()
entry.cats = cats
entry.save()
base = utils.origin(request) base = utils.origin(request)
perma = urljoin(base, entry.url) perma = urljoin(base, entry.url)