comparison comments/views.py @ 978:a828e80223d2

Prevent 500 error when previewing no text. Don't call image_check() when there is no data.
author Brian Neal <bgneal@gmail.com>
date Mon, 05 Oct 2015 20:26:14 -0500
parents d260aef91ad7
children 68c3343f3318
comparison
equal deleted inserted replaced
977:ba0f4a5f1fca 978:a828e80223d2
143 data = request.POST.get('data', None) 143 data = request.POST.get('data', None)
144 if data is None: 144 if data is None:
145 return HttpResponseBadRequest('No data') 145 return HttpResponseBadRequest('No data')
146 146
147 html = site_markup(data) 147 html = site_markup(data)
148 try: 148 if html:
149 image_check(html) 149 try:
150 except ImageCheckError as ex: 150 image_check(html)
151 html = PREVIEW_UNAVAILABLE.format(ex) 151 except ImageCheckError as ex:
152 html = PREVIEW_UNAVAILABLE.format(ex)
152 153
153 return render_to_response('comments/markdown_preview.html', { 154 return render_to_response('comments/markdown_preview.html', {
154 'data': html, 155 'data': html,
155 }, 156 },
156 context_instance = RequestContext(request)) 157 context_instance = RequestContext(request))