dont fail if info text does not exist
This commit is contained in:
parent
f871be3901
commit
4e433a7c5f
1 changed files with 9 additions and 6 deletions
|
@ -86,15 +86,18 @@ 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'])
|
||||
if text:
|
||||
response['data'] = text.json(user=request.user)
|
||||
return render_to_json_response(response)
|
||||
actions.register(getText)
|
||||
|
|
Loading…
Reference in a new issue