dont fail if info text does not exist

This commit is contained in:
j 2013-03-05 12:43:28 +00:00
parent f871be3901
commit 4e433a7c5f

View file

@ -86,15 +86,18 @@ def getText(request):
if public_id == '': if public_id == '':
qs = models.Text.objects.filter(name='') qs = models.Text.objects.filter(name='')
if qs.count() == 0: if qs.count() == 0:
text = models.Text() text = None
text.name = '' response['data'] = {
text.text = '' 'name': '',
text.status = 'public' 'text': '',
text.user = request.user 'type': 'html',
'editable': not request.user.is_anonymous() and request.user.get_profile().capability('canEditFeaturedTexts')
}
else: else:
text = qs[0] text = qs[0]
else: else:
text = get_text_or_404_json(data['id']) text = get_text_or_404_json(data['id'])
if text:
response['data'] = text.json(user=request.user) response['data'] = text.json(user=request.user)
return render_to_json_response(response) return render_to_json_response(response)
actions.register(getText) actions.register(getText)