From 4e433a7c5fb4fb50df6c8ae48942ec12374794b0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 5 Mar 2013 12:43:28 +0000 Subject: [PATCH] dont fail if info text does not exist --- pandora/text/views.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pandora/text/views.py b/pandora/text/views.py index 3e693012..617ee98b 100644 --- a/pandora/text/views.py +++ b/pandora/text/views.py @@ -86,16 +86,19 @@ def getText(request): if public_id == '': qs = models.Text.objects.filter(name='') if qs.count() == 0: - text = models.Text() - text.name = '' - text.text = '' - text.status = 'public' - text.user = request.user + text = None + response['data'] = { + 'name': '', + 'text': '', + 'type': 'html', + 'editable': not request.user.is_anonymous() and request.user.get_profile().capability('canEditFeaturedTexts') + } else: text = qs[0] else: text = get_text_or_404_json(data['id']) - response['data'] = text.json(user=request.user) + if text: + response['data'] = text.json(user=request.user) return render_to_json_response(response) actions.register(getText)