Hide likes and replies from the homepage

This commit is contained in:
Danielle McLean 2017-11-13 08:54:23 +11:00
parent 28e4a71cae
commit adb302ebe3
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
2 changed files with 10 additions and 3 deletions

View file

@ -1,8 +1,9 @@
class Entry:
def __init__(self, id, plural, icon, slug=False):
def __init__(self, id, plural, icon, on_home=True, slug=False):
self.id = id
self.plural = plural
self.icon = icon
self.on_home = on_home
self.slug = slug
@property
@ -46,12 +47,14 @@ Reply = Entry(
id='reply',
icon='fa fa-comment',
plural='replies',
on_home=False,
)
Like = Entry(
id='like',
icon='fa fa-heart',
plural='likes',
on_home=False,
)
Repost = Entry(
@ -61,5 +64,6 @@ Repost = Entry(
)
all = (Note, Article, Photo, Reply, Like, Repost)
on_home = (k.id for k in all if k.on_home)
from_id = {k.id: k for k in all}
from_plural = {k.plural: k for k in all}

View file

@ -3,9 +3,11 @@ from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.urls import reverse
from users.models import User
from lemoncurry import breadcrumbs, utils
from urllib.parse import urljoin
from entries import kinds
from lemoncurry import breadcrumbs, utils
breadcrumbs.add('home:index', 'home')
@ -13,10 +15,11 @@ breadcrumbs.add('home:index', 'home')
def index(request):
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
user = get_object_or_404(query, pk=1)
entries = user.entries.filter(kind__in=kinds.on_home)
return {
'user': user,
'entries': user.entries.all(),
'entries': entries,
'atom': 'entries:atom',
'rss': 'entries:rss',
'meta': user.as_meta(request),