From 32d71847584a77d917802a733bad5c4479aed282 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 21 Feb 2013 12:15:20 +0000 Subject: [PATCH] text.editable --- pandora/text/models.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pandora/text/models.py b/pandora/text/models.py index 63c95efed..585407005 100644 --- a/pandora/text/models.py +++ b/pandora/text/models.py @@ -62,7 +62,7 @@ class Text(models.Model): return self.user == user or self.status in ('public', 'featured') def editable(self, user): - if user.is_anonymous(): + if not user or user.is_anonymous(): return False if self.user == user or \ user.is_staff or \ @@ -144,7 +144,19 @@ class Text(models.Model): def json(self, keys=None, user=None): if not keys: - keys=['id', 'name', 'user', 'status', 'subscribed', 'posterFrames', 'description', 'text', 'type', 'links'] + keys=[ + 'description', + 'editable', + 'id', + 'links', + 'name', + 'posterFrames', + 'status', + 'subscribed', + 'text', + 'type', + 'user' + ] response = {} _map = { 'posterFrames': 'poster_frames' @@ -152,6 +164,8 @@ class Text(models.Model): for key in keys: if key == 'id': response[key] = self.get_id() + elif key == 'editable': + response[key] = self.editable(user) elif key == 'user': response[key] = self.user.username elif key == 'subscribers':