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,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)