Add cat support to the micropub endpoint, so new posts will have appropriate cats
This commit is contained in:
parent
829bb4a20f
commit
8b00cf8a1a
1 changed files with 8 additions and 1 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue