From bd441e995f2c3004b73d3d8ce60c376c7ff3a755 Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Fri, 27 Mar 2020 22:09:16 +0000 Subject: [PATCH] intermediate --- kepi/trilby_api/models.py | 7 ++++++- kepi/trilby_api/views.py | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/kepi/trilby_api/models.py b/kepi/trilby_api/models.py index 942e3b2..049dbf2 100644 --- a/kepi/trilby_api/models.py +++ b/kepi/trilby_api/models.py @@ -209,7 +209,12 @@ class Person(models.Model): @property def inbox(self): - return [] # FIXME + + def inbox_generator(): + for status in Status.objects.all(): + yield status + + return inbox_generator() @property def outbox(self): diff --git a/kepi/trilby_api/views.py b/kepi/trilby_api/views.py index 92aa823..93c2708 100644 --- a/kepi/trilby_api/views.py +++ b/kepi/trilby_api/views.py @@ -218,6 +218,10 @@ class Statuses(generics.ListCreateAPIView, safe = False, # it's a list ) + def _string_to_html(self, s): + # FIXME this should be a bit more sophisticated :) + return '

{}

'.format(s) + def create(self, request, *args, **kwargs): data = request.data @@ -228,9 +232,11 @@ class Statuses(generics.ListCreateAPIView, content = 'You must supply a status or some media IDs', ) + content = self._string_to_html(data.get('status')) + status = Status( account = request.user.person, - content = data.get('status'), + content = content, sensitive = data.get('sensitive', False), spoiler_text = data.get('spoiler_text', ''), visibility = data.get('visibility', 'public'), @@ -320,19 +326,7 @@ class HomeTimeline(AbstractTimeline): def get_queryset(self, request): - result = [] - - - for item in request.user.person.inbox: - if item.f_type in [ - 'Create', - ]: - product = item['object__obj'] - - if product is not None: - result.append(product) - - return result + return request.user.person.inbox ########################################